1

I'm using dojox.grid.EnhancedGrid which is created by the class MyGrid, explained below.

var MyGrid = declare(null, {
    constructor: function (app, id, opts) {
       this.id = id;
       this.app = app;
       this.core_id = app.getCoreId();

       var myStore;

       var jquery = {
         scope: 'core',
         command: 'rest',
         args: {
           resource: this.id,
           serve: 'cooked'
         },
         core_id: this.core_id
       };

       this.jsonStore = new custom.store.JsonRest({
         target: app.get_dispatcher_url(),
         jquery: jquery,
         // setstruct is an object to provide a method that sets a new
         // grid structure as soon as data arrives.
         set_structure: dojo.hitch(this, this.set_structure),
         app: this.app
       });

       // avoid closures from holding a reference
       // to jquery and preventing its GCing
       jquery = null;

       this.memoryStore = new Memory();
       myStore = new Cache(this.jsonStore, this.memoryStore);


       this.dataStore = new ObjectStore({
         objectStore: myStore,
         onSet: onEdited,
         onNew: onEdited,
         onDelete: onEdited
       });

       myStore = null;

       // create grid
       this.grid = new EnhancedGrid({
         store: this.dataStore,
         height: '100%',
         structure: [
           { name: 'Waiting for data...', field: 'no-field', width: '10em' }
         ],
         plugins: {
           menus: { rowMenu: this._create_menu() },
           nestedSorting: true,
           selector: { row: 'disabled', col: 'disabled', cell: 'multi' }
         }
       });

       // start grid
       this.grid.startup();
    }
}); 

Note that I omitted code to focus just on the creation of the "grid/store". MyGrid displays the grid on a ContentPane.

So I create an object to display the grid (with a large amount of data) and scroll to the bottom, and it will request only the visible rows properly. However, it just so happens that when I create a second grid it will request the content for the second grid and all data for the first grid!!

How can this happen? Any idea of what can be causing this?

EDITED (22/02/13):

I created a jsfiddle to demonstrate the problem I'm getting: see jsfiddle

How to reproduce the problem:

  1. Click on New Tab button, open the console and check how many rows were fetched.
  2. Go to the bottom of the grid (quickly) and check the console again.
  3. Click on New Tab again, go to the console and you can see that all rows, not loaded yet, from previous grid were fetched.

Note: I found out that this only happens on Google Chrome. I tested with Firefox and everything worked well.

Ivo Silva
  • 350
  • 4
  • 20
  • Can you add the code where you create your first and second grid? Hard to figure out what could ve happening without that information. – Default Feb 20 '13 at 00:02
  • I edited my original question and added a code snippet that creates the grid. The code is used to create both grids. – Ivo Silva Feb 20 '13 at 11:51
  • Hmm, nothing in particular jumps out at me. There may be some odd behavior in your widget because you are not extending _WidgetBase. You can try extending that (instead of null) and calling `this.grid.startup()` in your custom widget's `startup` method (don't forget `this.inherited(arguments)` if you do try that). – Default Feb 20 '13 at 14:25
  • If there was any way you could set up a jsfiddle to demonstrate this (obviously with Mock data, and probably just a DataStore instead of JsonRestStore), I think it would really help to isolate the problem since your code seems well formatted. – Default Feb 20 '13 at 14:29
  • I wanted to make an example in jsfiddle, but I have no idea how to load the data with `JsonStore` or at least emulate it. – Ivo Silva Feb 20 '13 at 21:14
  • 1
    You can make an example by removing the Cache and JsonRest store, and just set up a Memory store to take in an array of data. This will make the example simpler, and if the problem is reproducible, we know it is indeed your current structure (either the grid instantiation or the structure of your custom widget). If you cannot reproduce it without the Cache and JsonRest, then we know the problem resides in your data store. – Default Feb 20 '13 at 21:21
  • Finally I created an example on jsfiddle and found out that the problem only occurs in Chrome. Still, I have no idea why is this happening.. Thank you for the help, @Default!! – Ivo Silva Feb 22 '13 at 14:04
  • Any time @Ivo Silva. So after a little bit of playing around, I noticed that if you scroll slower through your data set in the grid (and make sure the first tab loads every piece of data), when you create the next tab it will not re-load the data. In fact, it isn't reloading ALL of the data, it is only loading what was never loaded in the first tab. It still isn't the right behavior, but it is a subtle difference. I'll see if I can figure out more. – Default Feb 22 '13 at 16:07
  • it works in chrome 25 for me. every time I add a new tab, it starts at gridx.0 up to gridx.499 where x is the number of the tab. – unludo Feb 24 '13 at 22:08
  • @unludo, maybe you didn't understand the problem. The grids are displaying their own items properly, like you pointed.. follow the 3 steps I wrote above and check the messages on your browser's console, you will see that grid1 will fetch some items from grid0. – Ivo Silva Feb 25 '13 at 15:42
  • ok I repoduced, maybe it messes with the events, did you try to trace them? Would be good to report to google? – unludo Feb 25 '13 at 20:40
  • No, I didn't trace any events, because I'm not sure what events should I trace or how.. If it ends up to be I browser's issue I can report it. – Ivo Silva Feb 25 '13 at 21:52

0 Answers0