0

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");
5
  • Have you tried using grid.setStore(<storeObject>) or grid.set('store', <storeObject>). Playing directly with dojo widget attributes is not recommended.
    – Himanshu
    Commented Jul 3, 2018 at 3:18
  • grid.setStore(<storeObject>) helps somehow. Now it shows 0 instead of NaN. But it breaks categorized structure of the tree. How do I properly refresh/reload it then?
    – John Glabb
    Commented Jul 3, 2018 at 3:41
  • Is there a grid.refresh() available? Can you use that instead of grid._refresh()?
    – Himanshu
    Commented Jul 3, 2018 at 3:51
  • Uncaught TypeError: grid.refresh is not a function
    – John Glabb
    Commented Jul 3, 2018 at 3:57
  • 1
    Please refer to my comment on your other question: link.
    – Himanshu
    Commented Jul 4, 2018 at 4:30

0