我无法将 selectionMode 保持为“single”或“extended”。当我使用 dojo Memory/ObjectStore 作为存储时,只会发生多行选择。
require([
"dojo/_base/declare",
"dojo/request",
"dojo/data/ObjectStore",
"dojo/store/Memory",
"dgrid/OnDemandGrid",
"dgrid/Keyboard",
"dgrid/Selection",
"dojo/DeferredList",
"dojo/domReady!"
],
function (declare, request, ObjectStore, Memory, OnDemandGrid, Keyboard, Selection, DeferredList) {
var ddstore;
claimDef = dojo.xhrGet({
url: "pageToGetData.aspx",
handleAs: "json",
load: function (res) {
// Resolve when content is received
ddstore = new Memory({ data: res });
}
});
var defs = new dojo.DeferredList([claimDef]);
defs.then(function (results) {
// Create a new constructor by mixing in the components
var CustomGrid = declare([OnDemandGrid, Keyboard, Selection]);
claimAccountsGrid = new CustomGrid({
columns: [
{ label: "Label1", field: "Field1" },
{ label: "Label2", field: "Field2" },
{ label: "Label3", field: "Field3" },
]
}, "claimAccountsGrid");
claimAccountsGrid.setStore(ddstore);
});
});
但是,当我对从该页面获得的相同数据进行硬编码时,我可以将默认 selectionMode 设置为“扩展”。(这种方式):
require([
"dojo/_base/declare",
"dojo/request",
"dojo/data/ObjectStore",
"dojo/store/Memory",
"dgrid/OnDemandGrid",
"dgrid/Keyboard",
"dgrid/Selection",
"dojo/DeferredList",
"dojo/domReady!"
],
function (declare, request, ObjectStore, Memory, OnDemandGrid, Keyboard, Selection, DeferredList) {
pageNo = 1;
var ddstore;
claimDef = dojo.xhrGet({
url: "pageToGetData.aspx",
handleAs: "json",
load: function (res) {
// Resolve when content is received
ddstore = //new Memory({ data: res });
[
{ "Field1": "value1", "Field2": null, "Field3": "1" },
{ "Field1": "value2", "Field2": null, "Field3": "1"}
];
}
});
var defs = new dojo.DeferredList([claimDef]);
defs.then(function (results) {
// Create a new constructor by mixing in the components
var CustomGrid = declare([OnDemandGrid, Keyboard, Selection]);
claimAccountsGrid = new CustomGrid({
columns: [
{ label: "Label1", field: "Field1" },
{ label: "Label2", field: "Field2" },
{ label: "Label3", field: "Field3" },
]
}, "claimAccountsGrid");
//claimAccountsGrid.setStore(ddstore);
claimAccountsGrid.renderArray(ddstore);
});
});