Hi,
I have been facing the following problem.
The grid is declared as follows.
<
telerik:RadGrid ID="RadGrid1" EnableViewState="true" runat="server" GridLines="Vertical" AllowFilteringByColumn="false" AutoGenerateColumns="false" AllowPaging="true" AllowCustomPaging="true" AllowSorting="true" ShowStatusBar="true" AllowMultiRowSelection="true" Height="600px">
Grid columns are defined as follows; Please note the DataKeyNames property.
<MasterTableView BorderStyle="None" BorderWidth="0" AllowCustomSorting="true" DataKeyNames="col1">
<telerik:GridBoundColumn UniqueName="item_num" DataField="item_num" DataType="System.Int32" SortExpression="item_num"
HeaderText="item number">
</telerik:GridBoundColumn>
I have multi row select enabled on the grid. After selecting multiple rows, I run the following Javascript to get the value of the data key for those rows but it returns null for
var radgrdItems = $find("<%=RadGrid1.ClientID %>");
var mtv = radgrdItems.get_masterTableView();
// Get array of GridDataItem
var selectedRows = mtv.get_selectedItems();
// Works as expected. Returns the count of selected rows.
alert(selectedRows.length);
for (var i = 0; i < selectedRows.length; i++) {
var row = selectedRows[i];
if (row == null)
alert("row is null");
else {
// Works as expected - Returns the id
alert("get_id()= " + row.get_id());
// Does not work! Returns null for the get_dataItem()["item_num"]
alert("item #=" + row.get_dataItem()["item_num"]);
// Does not work! Returns null for the row.getDataKeyValue("col1")
alert("col1 key value=" + row.getDataKeyValue("col1"));
}
}
What am I doing wrong?
I have already looked @ http://demos.telerik.com/aspnet-ajax/grid/examples/client/keys/defaultcs.aspx page and could not find the issue in my code (may be I am missing something?)
Any help is appreciated.
Thanks,
Manny