How can i get the Row ID by clicking on it? Actually I want to assign the remote table's row ID to each row of the Grid and by clicking on it, I want to load the second grid. Any solution?
How can i get the Row ID by clicking on it? Actually I want to assign the remote table's row ID to each row of the Grid and by clicking on it, I want to load the second grid. Any solution?
Share Improve this question edited Apr 5, 2013 at 2:36 hakre 198k55 gold badges449 silver badges855 bronze badges asked Feb 3, 2012 at 15:12 EdgeEdge 9111 gold badge12 silver badges19 bronze badges2 Answers
Reset to default 5Here you go http://jsfiddle/qvKRk/
JavaScript
var dataSample = [];
dataSample.push({
OrderID: "1",
ShipName: "line 1"
});
dataSample.push({
OrderID: "2",
ShipName: "line 2"
});
dataSample.push({
OrderID: "3",
ShipName: "line 3"
});
var dataSource = new kendo.data.DataSource({
data: dataSample,
schema: {
model: {
id: "OrderID"
}
},
pageSize: 10
});
$("#grid").kendoGrid({
dataSource: dataSource,
selectable: true,
columns: ["OrderID", "ShipName"],
change: function () {
var row = this.select();
var id = row.data("id");
$("#log").html("selected row with id= " + id);
// sample selecting same row on second grid
// based on this post
var secondGrid = $("#grid2").data("kendoGrid");
var row = secondGrid.table.find('tr[data-id="' + id + '"]');
secondGrid.select(row);
}
});
$("#grid2").kendoGrid({
dataSource: dataSource,
selectable: true,
columns: ["OrderID", "ShipName"]
});
HTML
master grid :
<br />
<div id="grid"></div>
<div id="log"></div>child grid :
<br />
<div id="grid2"></div>
var grid = $("#GridSearchResults").data("kendoGrid");
var cel;
grid.select().each(function() {
var dataItem = grid.dataItem($(this));
cel = dataItem.InventoryItemId;
});
The Cell will Contain the column you like to extract once a row is selected. Note:Make Sure You Enable Selection in the Grid.