最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Kendo Grid Row Selection - Stack Overflow

programmeradmin3浏览0评论

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 badges
Add a ment  | 

2 Answers 2

Reset to default 5

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

发布评论

评论列表(0)

  1. 暂无评论