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 を「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);
});
});