This is a migrated thread and some comments may be shown as answers.

RadGrid - Detail Table Bind, Client-side event?

3 Answers 156 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 14 Oct 2008, 05:47 PM
Is there any client-side event that will fire after the detail table is expanded or collapsed? 

I'm trying to solve this problem: I have a CommandItemTemplate with a LinkButton which should only be enabled when the number of selected rows > 0.  The JS works fine, when linked to ClientEvents-OnRow{Selected|Deselected}.  The problem comes when the row expands, and the ItemCommand is fired in conjunction with the BindDetailTable.  After this event, the LinkButton is never again seen.

I have tried ItemCommand code-behind to set the Style["visibility"] = "none" (or "inline", if SelectedItems.Count>0), and I have tried a plethora of the ClientEvents-On* but nothing seems to work.

Here is the JS function which works as long as the detail table is not expanded:

function ConditionallyEnableClearButton(sender, eventArgs) { 
    var masterTableView = sender.get_masterTableView(); 
    var selectedItems = masterTableView.get_selectedItems(); 
    var visibility = selectedItems.length > 0 ? "inline" : "none"
 
    var button = document.getElementById('<%= AlertGrid.MasterTableView.GetItems(GridItemType.CommandItem)[0].FindControl("ClearButton").ClientID %>'); 
    if (button) { 
        button.style.display = visibility; 
    } 
 

And here is the ItemCommand code-behind:

LinkButton clearButton = 
                grid.MasterTableView.GetItems(GridItemType.CommandItem)[0].FindControl(CLEAR_BUTTON) as LinkButton; 
var oldValue = clearAlertsButton.Style["display"]; 
clearAlertsButton.Style["display"] = grid.SelectedItems.Count > 0 ? "inline" : "none"
 

I think a pure JS solution would work, if I could hook up the JS function to the end of the expand or collapse event, client-side.

Thanks,
Tim

3 Answers, 1 is accepted

Sort by
0
Tim
Top achievements
Rank 1
answered on 14 Oct 2008, 06:40 PM
Having written a macro to generate ALL the client side events, I have determined that ClientEvents-OnGridCreated will do the trick - fired at the very end of the row expansion.

Anyone think this is wrong?

Tim

0
Sebastian
Telerik team
answered on 17 Oct 2008, 07:37 AM
Hi Tim,

Interceoting the OnGridCreated client event might be one possible solution for your situation.

In addition, note that RadGrid exposes OnHierarchyExpanding/OnHierarchyExpanded as well as OnHierarchyCollapsing/OnHierarchyCollapsed client-side events which are meaningful with HierarchyLodeMode set to Client:

http://www.telerik.com/help/aspnet-ajax/clientevents_members.html

They are demonstrates in this online demo of the product:

http://demos.telerik.com/ASPNET/Prometheus/Grid/Examples/Hierarchy/HierarchyLoadModeClient/DefaultCS.aspx

Best regards,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Tim
Top achievements
Rank 1
answered on 17 Oct 2008, 01:24 PM
OnHierarchyExpanding/OnHierarchyExpanded as well as OnHierarchyCollapsing/OnHierarchyCollapsed client-side events which are meaningful with HierarchyLodeMode set to Client:

Thanks, but I'm not using HiearchyLoadMode so that does not help me.  Based on the demo, it was one of the first things I did try.

Tim

Tags
Grid
Asked by
Tim
Top achievements
Rank 1
Answers by
Tim
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or