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

Client-side expand/collapse

2 Answers 129 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Laurent Lannelucq
Top achievements
Rank 1
Laurent Lannelucq asked on 31 Mar 2009, 09:01 AM
Bonjour,

I would like to add a label/button/... in the CommandItem to expand or collapse the whole hierarchy of my grid. This operation is easy to do server-side but I have to do it on client-side. Is it possible ?

Thanks you.

Amicalement,

Laurent.



2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 31 Mar 2009, 09:51 AM
Hello Laurent,

You can try out the following code to expand or collapse the rows in a grid on clicking a button in the CommandItemTemplate:
aspx:
      <CommandItemTemplate> 
          <asp:LinkButton ID="LinkButton3" OnClientClick="expandcollapse()" runat="server">Expand/Collapse</asp:LinkButton> 
      </CommandItemTemplate> 

cs:
 function expandcollapse() 
 {  
   var grid=$find("<%=RadGrid2.ClientID %>"); 
   var table=grid.get_masterTableView(); 
   
   var rows = table.get_dataItems(); 
   for (var i = 0; i < rows.length; i++)    
   {    
      var Row = rows[i]; 
        if(Row.get_expanded() == false)   
            {   
                Row.set_expanded(true);                  
                 
            }   
            else  
            {   
                Row.set_expanded(false);   
            } 
    } 
 } 

Thanks
Princy.
0
Pavlina
Telerik team
answered on 31 Mar 2009, 03:19 PM
Hi Laurent,

The Client-side expand/collapse functionality is demonstrated in the following online resources:
Expand/collapse grouped grid client-side on external control click
Expand/collapse hierarchy client-side on double click

Feel free to utilize the logic presented their for your case in order to attain the functionality you are after.

Best wishes,
Pavlina
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Laurent Lannelucq
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Pavlina
Telerik team
Share this question
or