I have a grid, which allows multi select. This current set of results returns only one row. I click on that row. When using "MasterTable.get_selectedItems().length" in a function, its value is 0. I click the row a second time and it is 1. Why isn't it 1 the firs time, like it should be? I need this to work correctly.
4 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 17 Apr 2013, 12:41 PM
Hi,
Unfortunately I couldn't replicate the issue. Please take a look into the sample code snippet I tried.
ASPX:
Javascript:
Thanks,
Princy.
Unfortunately I couldn't replicate the issue. Please take a look into the sample code snippet I tried.
ASPX:
<telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1" AllowMultiRowSelection="true" AutoGenerateColumns="false" runat="server"> <MasterTableView> <Columns> <telerik:GridBoundColumn DataField="OrderID"> </telerik:GridBoundColumn> </Columns> </MasterTableView> <ClientSettings Selecting-AllowRowSelect="true"> <ClientEvents OnRowSelected="OnRowSelected" /> </ClientSettings></telerik:RadGrid>Javascript:
<script type="text/javascript"> function OnRowSelected(sender, args) { var len = sender.get_masterTableView().get_selectedItems().length; alert(len); }</script>Thanks,
Princy.
0
Stacy
Top achievements
Rank 1
answered on 17 Apr 2013, 12:54 PM
Try using the "OnRowClick" method. It is here that the length will be 0 on the first click, then 1 if you click on the row a second time.
0
Princy
Top achievements
Rank 2
answered on 18 Apr 2013, 03:08 AM
Hi Stacy,
As far as I know you will not get the selected row count correctly in the row click event, because the the 'OnRowClick' event is fired before the Row is selected. Please elaborate the scenario , so that i can help you.
Thanks,
Princy.
As far as I know you will not get the selected row count correctly in the row click event, because the the 'OnRowClick' event is fired before the Row is selected. Please elaborate the scenario , so that i can help you.
Thanks,
Princy.
0
Stacy
Top achievements
Rank 1
answered on 18 Apr 2013, 12:12 PM
If the issue is timing, I will just use the OnRowSelected event instead. Thanks.