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

Select All Rows

1 Answer 97 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mitul
Top achievements
Rank 1
Mitul asked on 14 Jul 2008, 02:10 PM
Hi All,

My client requires that instead of clicking on the checkbox above, there be a button which reads "select all" at a different place on the page, by which the user can select all the rows of the radgrid. Similarly another button to clear all selections. Is there a way in whcih i can do this? I could not find anything on the forums so far.

Cheers,
M

1 Answer, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 14 Jul 2008, 03:25 PM
Hi Mitul,

Thank you for contacting us and for your question.

You can try the following snippet for selecting/ deselecting all rows in RadGrid
       <script type="text/javascript">  
            function deSelectAllRows()  
            {  
                var masterTable = $find("<%= RadGrid1.ClientID %>").get_masterTableView();    
                masterTable.clearSelectedItems();  
                  
                return false;  
            }  
              
            function selectAllRows()  
            {                                  
                var masterTable = $find("<%= RadGrid1.ClientID %>").get_masterTableView();  
    
                masterTable.clearSelectedItems();  
                for(var i =0;i<masterTable.get_dataItems().length;i++)  
                    masterTable.selectItem(masterTable.get_dataItems()[i].get_element());  
                  
                return false;  
            }  
        </script> 

Also make sure that AllowMultiRowSelection="true" and

<ClientSettings> 
 <Selecting AllowRowSelect="true" /> 
</ClientSettings> 

You can find more info here.

Regards,
Nikolay
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
Mitul
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Share this question
or