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

Client API for Select All

4 Answers 58 Views
Grid
This is a migrated thread and some comments may be shown as answers.
miksh
Top achievements
Rank 1
Iron
miksh asked on 24 Sep 2008, 11:32 AM
Is there any way on the client side to simulate behaviour of Select All checkbox in the header of  GridClientSelectColumn to Select All/Unselect All items?

4 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 24 Sep 2008, 01:13 PM
Hi,

Try the following JavaScript code to select and deselect items on the client side.

ASPX:
   <asp:Button ID="Button1" runat="server" Text="SelectAll"  OnClientClick="SelectAll()"/> 
        <asp:Button ID="Button2" runat="server" Text="DeselectAll" OnClientClick="DeselectAll()" /> 

JS:
<script  language="javascript" type="text/javascript"
   function SelectAll() 
   { 
       var masterTable = $find("<%= RadGrid1.ClientID %>").get_masterTableView(); 
       for(var i=0;i<=masterTable.get_dataItems().length;i++) 
         { 
             masterTable.selectItem(masterTable.get_dataItems()[i].get_element()); 
         } 
   } 
   function DeselectAll() 
   { 
   var masterTable = $find("<%= RadGrid1.ClientID %>").get_masterTableView(); 
       for(var i=0;i<=masterTable.get_dataItems().length;i++) 
         { 
             masterTable.deselectItem(masterTable.get_dataItems()[i].get_element()); 
         } 
   } 
     
     </script> 


Thanks
Shinu.
0
miksh
Top achievements
Rank 1
Iron
answered on 24 Sep 2008, 01:16 PM
Thanks.
It would great if you add such Client API methods in next releases.
0
Princy
Top achievements
Rank 2
answered on 24 Sep 2008, 01:49 PM
Hi,

You can get this implemented by setting AllowMultiRowSelection property of the grid to true with the GridClientSelectColumn.
aspx:
<telerik:RadGrid ID="RadGrid1" AllowMultiRowSelection="True"  DataSourceID="SqlDataSource1" > 
 <MasterTableView DataSourceID="SqlDataSource1" >    
  <Columns> 
          <telerik:GridClientSelectColumn></telerik:GridClientSelectColumn>         
  </Columns> 
 </MasterTableView> 
</telerik:RadGrid > 

Thanks
Princy.
0
miksh
Top achievements
Rank 1
Iron
answered on 24 Sep 2008, 02:12 PM
I'm aware of this feature. In my question I meant the scenarios where I need to select/unselect all items programmatically on the client-side based on various page events. So a single grid client API method would help very much.
Tags
Grid
Asked by
miksh
Top achievements
Rank 1
Iron
Answers by
Shinu
Top achievements
Rank 2
miksh
Top achievements
Rank 1
Iron
Princy
Top achievements
Rank 2
Share this question
or