简体   繁体   中英

Kendo Grid Row Selection

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?

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>
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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM