[英]How get row state (selected or not) in kendo grid
I have a kendo ui grid with multiple selected rows and I need to get all rows and there state (selected or not) for an ajax request. 我有一个带有多个选定行的kendo ui网格,我需要获取所有行,并为ajax请求指定(选择与否)。 How I can do that ?
我怎么能这样做? this is my code, thanking you :
这是我的代码,感谢你:
function () {
var entityGrid = $("#archivesGrid").data("kendoGrid");
var rows = entityGrid.dataSource.data();
var totalItem = rows.length;
var items = [];
for(var i = 0; i < totalItem; i++) {
var currentItem = rows[i];
items.push({
name: currentItem.DataAddress.Address,
selected: true // Attributes ?
});
}
}
I know how I can have selected rows with select() but there isn't an attribute or something in dataItem to know if it select or not ? 我知道如何用select()选择行,但dataItem中没有属性或东西来知道它是否选择?
To get all rows and their states you could query for .k-state-selected. 要获取所有行及其状态,您可以查询.k-state-selected。 Something like the below will return the uid and it's state:
像下面这样的东西将返回uid及其状态:
function getStates() {
var rowStates = {};
$("#archivesGrid tbody").find('tr').each(
function () {
var id = $(this).data("uid");
var selected = $(this).hasClass('k-state-selected');
rowStates[id] = selected;
}
);
return rowStates;
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.