I have a problem with the get_selectedItems()
function.
I use RadGrid
from Telerik
. Great controls, but now I stumbled on a bug which I can not solve.
When selecting a row, I call the RowSelectionChanged
function on the client side and then I'll get an exception.
Could anyone tell me why sender.get_selectedItems()[0]
is null while sender.get_selectedItems().length
is at least 1?
<telerik:RadCodeBlock runat="server" ID="RadCodeBlock1">
<script type="text/javascript">
function RowSelectionChanged(sender, eventArgs) {
if (sender != null) {
for (i = 0; i < sender.get_selectedItems().length; i++) {
var it = sender.get_selectedItems()[i]; // it is null
var element =it.get_element(); // throws exception
}
}
}
</script>
</telerik:RadCodeBlock>
<telerik:RadGrid ID="rgTest" runat="server" >
<MasterTableView>
<Columns>
<telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" />
<telerik:GridBoundColumn DataField="guid" />
</Columns>
</MasterTableView>
<ClientSettings EnableRowHoverStyle="true">
<ClientEvents OnRowSelected="RowSelectionChanged" />
<Selecting AllowRowSelect="true" />
</ClientSettings>
</telerik:RadGrid>
Function get_selectedItems()
should be invoked NOT on RadGrid object but on MasterTableView object.
This code works for me:
<telerik:RadCodeBlock runat="server" ID="RadCodeBlock1">
<script type="text/javascript">
function RowSelectionChanged(sender, eventArgs) {
if (sender != null) {
var masterTable = sender.get_masterTableView();
for (i = 0; i < masterTable.get_selectedItems().length; i++) {
var it = masterTable.get_selectedItems()[i];
var element =it.get_element();
}
}
}
</script>
</telerik:RadCodeBlock>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With