我在 Dgrid ondemandgrid 中使用 Selector 和 Selection Mixin。我使用复选框作为选择器。以下是我的问题。
- 如何在 html 按钮单击时获取 javascript 中已检查行的列表?我知道有一个 dgrid-select 和取消选择事件,但我想要按钮单击事件上所有选定行的列表。
- 目前,如果我点击任何位置的一行,复选框就会被选中。但我只想在点击复选框时选择该行。如何实现这一点?
这是我的代码
require([
"dgrid/OnDemandGrid",
"dojo/store/JsonRest",
"dojo/dom",
"dojo/dom-style",
"dojo/_base/declare",
"dgrid/extensions/ColumnResizer",
"dgrid/Selection",
"dgrid/selector"
], function (OnDemandGrid,JsonRest,dom,domStyle,declare,ColumnResizer,Selection, selector) {
var Layout = [
selector({ label: selector({}), selectorType: "checkbox" }),
{field: 'srno',label: 'Sr No'},
{field: "Name",label: "name"}
];
jsonstore = new JsonRest({target: url,idProperty: "srno"});
grid = new(declare([OnDemandGrid,ColumnResizer,Selection]))({
store: jsonstore,
columns: Layout,
minRowsPerPage : 40,
maxRowsPerPage : 40,
keepScrollPosition : true,
allowSelectAll: true,
loadingMessage: "Loading data...",
noDataMessage: "No results found."
}, "grid");
domStyle.set(dom.byId("grid"),"height","210px");
grid.startup();
grid.on("dgrid-select", function(event){
//
});
grid.on("dgrid-deselect", function(event){
//
});
});