我无法将selectionMode保持为“单个”或“扩展”。 当我使用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设置为“extended”。(这样):
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);
});
});
答案 0 :(得分:2)
由于您还没有显示实际数据,因此我无法100%确定,但如果您未能正确确保您的商品具有唯一标识符(或者,如果标识符字段为除id
之外的其他内容,您忘记在内存存储区设置idProperty
以告知它要查看的字段。)