将选定的Kendo Grid项添加到另一个Grid

时间:2013-02-05 01:17:32

标签: asp.net-mvc kendo-ui

我的页面中有两个Kendo网格。其中一个绑定到ASP.NET MVC操作。启用多个部分。我想将选定的网格项添加到我的第二个网格。

<div id="grid1"></div> -- This Grid holds Master Data
<div id="grid2"></div> -- This Grid should hold Selected items of Grid One

$("#grid1").kendoGrid({

    sortable: true,
    selectable: "multiple row",
    pageable: true,
    change: onchange  ,
    filterable: true,
    dataSource: {
        transport: {
            read: "/Home/getPeople",
            datatype: "json"
        },
        pageSize:10
    },
    columns: [
        { field: "Id", title: "Id", template: '<input id=\'#=Id#\' class="personId" type=\"checkbox\"/>' },
        { field:"FirstName", title:"First Name",sortable:true },
        { field:"MiddleName", title:"Middle Name", sortable:true },
        { field: "LastName", title: "LastName", sortable: true },
    ]
});

$("#grid2").kendoGrid({

    sortable: true,
    selectable: "multiple row",
    pageable: true,
    filterable: true,
    dataSource: { -- Here i need to bind it with the selected items of Grid1.

    },
    columns: [
        { field: "Id", title: "Id", template: '<input id=\'#=Id#\' class="personId" type=\"checkbox\"/>' },
        { field: "FirstName", title: "First Name", sortable: true },
        { field: "MiddleName", title: "Middle Name", sortable: true },
        { field: "LastName", title: "LastName", sortable: true },
    ]
});

function onchange() {   
    var text = "";
    var grid = this;                

    grid.select().each(function() {
        var dataItem = grid.dataItem($(this));
        text += "First Name is: " + dataItem.FirstName + "\n";

        alert(text);
    });



}   

    ----I am capturing onChange event to Alert it's value but could not firgure out how it can be added to Grid2 and how on Submit i can only POST items that exist in Grid

   </script>

0 个答案:

没有答案