3

I have problem in DOJO with DataGrid. I refresh my grid on every 1 sec with this code

window.store_data_log= new dojo.data.ItemFileReadStore({data:{items:temp}});
var grid = dijit.byId("grid_log");
grid.setStore(window.store_data_log);

and it works fine ( put new data ). Problem is that when I have lot off rows and I scroll down, my grid refreshs and my scroll goes on top grid. How to solve this ?

Damir
  • 54,277
  • 94
  • 246
  • 365

2 Answers2

2

Of course, you are totally clearing the store and resetting it every second from scratch. When you reset the store, you basically reset the grid. I would expect nothing less than the grid resetting the scroll position when you refresh its store.

You may want to learn how to properly use the store rather than just trying to reset it. I answered this here:

How to refresh datagrid

If you use dojo properly, you will get good results, but by just taking a shortcut and trying to refresh the store every second you are going to get an unusable grid.

You need to take a step back and solve your application architecture and not expect the grid refresh to be some kind of magic solution.

Community
  • 1
  • 1
Tom Gruner
  • 9,635
  • 1
  • 20
  • 26
0

After going through (dojo) datagrid.js, I found how to resolve the issue:

//datastore you're using//
var store = new dojox.data.QueryReadStore({ 
   //in the fetch()//
   fetch: function (request){
        //add the following://
        request.isRender = false; 
   }
});

Important: Only set request.isRender to false when you don't want the grid to scroll back to the top. Just keep in mind that some situations (like sorting on a new column), it's probably best to set it to true. Just add some if/else statements to help with the logic.

AROE
  • 93
  • 3