Welcome Guest Search | Active Topics | Sign In | Register

Partial Datagrid Update with CallBackPanel?? Options
brado426
Posted: Saturday, July 7, 2007 12:38:37 PM
Rank: Member
Groups: Member

Joined: 7/7/2007
Posts: 19
Hi Support!

I'm evaluating this product right now and so far I'm very impressed.

I have a Menu inside of a CallBack panel inside of a Template Column in my DataGrid. When a Menu Item is selected, I have it dynamically update the menu just like the example.

Everything works fine except that instead of updating just the cell portion of the screen where the menu resides, it is updating the entire datagrid.

Therefore, the more rows that are in my DataGrid, the longer it takes for the screen to repaint each time the user selects a menu item. If the DataGrid was inside of the Callback panel, I would understand this behavior.

Any ideas of what I might be doing wrong? Is this normal behavior?

Brad O.
eo_support
Posted: Saturday, July 7, 2007 5:00:54 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
hi, Brad

Thanks for posting your question here.
Could you post your code out or, if you like, you can email us your code and we can have a look.

Thanks.
brado426
Posted: Saturday, July 7, 2007 6:12:21 PM
Rank: Member
Groups: Member

Joined: 7/7/2007
Posts: 19

Code is here:

Code
eo_support
Posted: Sunday, July 8, 2007 11:59:07 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Thanks for posting the code. We are working on it and will let you know as soon as we find anything.
eo_support
Posted: Sunday, July 8, 2007 1:14:10 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi Brad,

We tried your code with the following modifications since we do not have your data source:

1. Removed all columns except the TemplateColumn which contains our CallbackPanel;
2. Added a single fixed menu item into the menu;
3. Changed mnuStatus_ItemClick event to:

Code: C#
protected void menuStatus_ItemClick(
    object sender, EO.Web.NavigationItemEventArgs e)
{
    EO.Web.MenuItem item = (EO.Web.MenuItem)e.NavigationItem;
    item.Text.Html = System.Environment.TickCount.ToString();
}


4. In Page_Load, we do:

Code: C#
private void Page_Load(object sender, System.EventArgs e)
{
    gridHTList.DataSource = new string[3];
    gridHTList.DataBind();
}


We then run the page and see three rows in the grid. We click on the single menu item of any row and the menu item text changes to the current system tick count. None of the other rows menu item changes text.

As such it appears that the problem that you are seeing is not happening at here. Can you try the above code on your machine and see what happens?

If it behaves the same on your machine, then you may want to verify whether the DataGrid is indeed completely updated with your original code ---- it seems to be almost impossible to us because the CallbackPanel defines the boundary of the region to be updated, and it is not likely that our controls would automatically steps over that boundary and arbitrarily stops on the DataGrid and use that control as the update boundary.

The slowless that occurs when you have more rows however does make sense. The reason is because regardless how small the portion that needs to be updated by a CallbackPanel, the whole page needs to be re-rendered. This is necessary because sometimes one control inside the CallbackPanel would reference controls outside of the CallbackPanel, so it is impossible to guarantee the consistency without also rendering other controls. Such rendering takes time, especially when you have a menu, which is a quite heavy control, inside your TemplateColumn.

One way to improve this is to use a dynamically updated context menu. Essentially you have one single menu on the page, you will then update the menu item text right before you display it. This solution works very well if the menu item structures for all rows are the same. You can find a sample demonstrating this technique at here:

http://www.essentialobjects.com/demo/Default.aspx?path=Menu\menu_programming\_i2\grid_context_menu

Let us know if you still have any questions.

Thanks
brado426
Posted: Monday, July 9, 2007 8:49:56 AM
Rank: Member
Groups: Member

Joined: 7/7/2007
Posts: 19
I have implemented your suggestion and I think that using the JavaScript and the ContextMenu is the best possible solution for what I'm trying to do.

I really appreciate the assistance. It looks to me as though the awesome support provided for these controls is worth the purchase-price alone. :)

I'm going to finish this up, prove that it works 100%, and buy the controls.

Brad O.
eo_support
Posted: Monday, July 9, 2007 9:01:49 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Thanks for the update. It's always good to hear that our users are very happy with our support. Please feel free to let us know if there is anything else we can help.
brado426
Posted: Monday, July 9, 2007 11:42:02 AM
Rank: Member
Groups: Member

Joined: 7/7/2007
Posts: 19
eo_support:

I have my menu popping up when the user clicks as needed. The problem I've run into is that I need to update the cell that the link is in after the user selects an item on the menu. The actual ContextMenu control is no longer in the cell... it is actually outside of the DataGrid now, so I can't get the row ID anymore.

I'm thinking I need to somehow pass the ID to the menu control when the user clicks on the link and then pass that ID again during the clientonclick event to my JavaScript that updates the cell that the link is located within.

Can you recommend the best approach for this? Unfortunately, I'm not a JavaScript expert. :(

Brad O.
eo_support
Posted: Monday, July 9, 2007 12:18:22 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi Brad,

The context menu should be outside of the DataGrid. However if you look at the sample, you will see the link elements that is inside ItemTemplate have different parameter for different rows. The sample code uses:

Code: HTML/ASPX
javascript:ShowContextMenu(
    event, <%#((DbDataRecord)Container.DataItem)["ID"]%>);


To pass ShowContextMenu the record ID of the given row. You can change it to anything you'd like.

You can then use a global variable to remember the last ID this way:

Code: JavaScript
var g_LastID = null;

function ShowContextMenu(e, id)
{
    //Save the last ID
    g_LastID = id;

    //Modify the menu
    ......

    //Show the context menu
    eo_ShowContextMenu(e, "&lt;%=Menu1.ClientID%&gt;");
}

function on_context_menu_click(e, info)
{
    //now use g_LastID to do whatever you need
    .....
}


Thanks
brado426
Posted: Monday, July 9, 2007 9:58:45 PM
Rank: Member
Groups: Member

Joined: 7/7/2007
Posts: 19
Sorry to bug you again. I thought I was home-free, but I keep on running into issues that are driving me nuts. I haven't worked with JavaScript for quite some time (been trying to do everything with .NET).

I have everything working up to this point.... I have my on_context_menu_click(e, info) function with my ID variable in it. Now I'm having trouble figuring out how to update the data in my datagrid. When I update the data with JavaScript InnerHtml, the server doesn't know about it and I lose everything on postback. How am I supposed to get the data contained within "info* back to my code-behind so that I can write the changes that were made out to the database?

I found this:

http://groups.google.com/group/microsoft.public.dotnet.general/browse_thread/thread/53b13f865e2229a/cf53ace1b607e1e1?lnk=st&q=javascript+variable+to+codebehind&rnum=52#cf53ace1b607e1e1

Is placing the data into an INPUT field the appropriate way to do this in .NET? Or is there a more elegant way? My lack of experience in this area is making this very frustrating. :(

Brad O.
eo_support
Posted: Tuesday, July 10, 2007 6:43:10 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Yes. Hidden INPUT fields are very often used exactly for the purpose of storing arbitrary data. .NET itself uses hidden input field to store view state data. So there is nothing non-elegant about it. :)
brado426
Posted: Tuesday, July 10, 2007 7:36:05 AM
Rank: Member
Groups: Member

Joined: 7/7/2007
Posts: 19
Ok, I'll give that a try. Half the battle is knowing the correct method to use. Thanks for the guidance.
brado426
Posted: Wednesday, July 11, 2007 10:00:06 AM
Rank: Member
Groups: Member

Joined: 7/7/2007
Posts: 19
Ok. I finally have it working 100%! The other thing that was stumping me was how to reference the ASP.NET control IDs since it is hard to predict how they would be named. I found that pushing JavaScript variables to the client that contains the ASP.NET ClientID works like a charm. Now I am able to find my hidden input fields, populate them, and access the data from Codebehind with minimal JavaScript. Thanks so much!

Brad O.
eo_support
Posted: Wednesday, July 11, 2007 10:03:10 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Great to hear that! Thanks for the update!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.