2

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?

2 Answers 2

5

Here you go http://jsfiddle.net/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>
0
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.