[英]Kendo Grid get selected row from all pages
I want to fetch a selected data from all the pages.我想从所有页面中获取选定的数据。
For example I select 1 item from the page 1 and the 2nd item from the page 2. When I click on the button (Get Checked Rows).例如,我 select 第 1 页的 1 个项目和第 2 页的第 2 个项目。当我单击按钮(获取选中的行)时。 I want to fetch those id's that I just selected from the different pages.
我想获取我刚刚从不同页面中选择的那些 ID。
So far this is what I found, but it works for a single pages only.到目前为止,这是我发现的,但它仅适用于单个页面。 FULL DEMO
完整演示
var grid = $("#grid").data("kendoGrid");
var selectedRows = grid.select();
selectedRows.each(function(index, row) {
var selectedItem = grid.dataItem(row);
alert(selectedItem.ProductID);
});
Is there any other way, instead creating a template/id for a checkbox.有没有其他方法,而不是为复选框创建模板/ID。
You need to use the selectedKeyNames method rather than the select method.您需要使用 selectedKeyNames 方法而不是 select 方法。
If you update your code like this ( updated DEMO ), you can see it work:如果你像这样更新你的代码(更新的 DEMO ),你可以看到它的工作:
$("#button").kendoButton({
click: function(e){
var grid = $("#grid").data("kendoGrid");
var selectedRows = grid.select();
//show all selected keys across all pages
alert(grid.selectedKeyNames());
selectedRows.each(function(index, row) {
var selectedItem = grid.dataItem(row);
alert(selectedItem.ProductID + ' | ' + selectedItem.ProductName);
});
}
});
More info and a Telerik example can be found here: https://docs.telerik.com/kendo-ui/knowledge-base/checkbox-selection-dataitems-selected-rows可以在此处找到更多信息和 Telerik 示例: https://docs.telerik.com/kendo-ui/knowledge-base/checkbox-selection-dataitems-selected-rows
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.