问题
I have dojo treeGrid that shows totals for child items. Everything works fine. But if I replace/update store and refresh then aggregation doesn't work and all totals shown as NaN. What am I doing wrong?
var layout = [
{ cells: [
[ {field: "userName", name: "Name"},
{field: "childItems",
children: [ { field: "debit", name: "debit"},
{ field: "credit", name: "credit"}
],
aggregate: "sum"
}
]] } ]
var jsonStore = new dojo.data.ItemFileWriteStore({ url: "<............>"});
var grid = new dojox.grid.TreeGrid({
structure: layout,
store: jsonStore,
query: {type: 'year'},
queryOptions: {deep: true},
rowSelector: true,
openAtLevels: [false],
autoWidth: true,
autoHeight: true
},
dojo.byId("treeGrid"));
//replace store button
var button = dojo.query("[id$=':buttonReplace']")[0];
dojo.on(button,'click',
function(e){
grid.store.close();
grid.store = new dojo.data.ItemFileWriteStore({ url: "<... new store url...>"});
grid._refresh();
}
);
grid.startup();
dojo.connect(window, "onresize", grid, "resize");
来源:https://stackoverflow.com/questions/51130123/dojo-treegrid-aggregate-not-working-after-refreshing-jsonstore