1

我使用dojox.grid.EnhancedGrid的是由类创建的MyGrid,如下所述。

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();
    }
}); 

请注意,我省略了代码以仅关注“网格/存储”的创建。MyGrid在 ContentPane 上显示网格。

所以我创建了一个对象来显示网格(有大量数据)并滚动到底部,它只会正确请求可见的行。然而,碰巧当我创建第二个网格时,它会请求第二个网格的内容第一个网格的所有数据!!

这怎么可能发生?知道是什么原因造成的吗?

已编辑(22/02/13):

我创建了一个 jsfiddle 来演示我遇到的问题:请参阅 jsfiddle

如何重现问题:

  1. 单击新选项卡按钮,打开控制台并检查获取了多少行。
  2. 转到网格底部(快速)并再次检查控制台。
  3. 再次单击新选项卡,转到控制台,您可以看到之前网格中尚未加载的所有行都已获取。

注意:我发现这只发生在Google Chrome上。我用Firefox进行了测试,一切正常。

4

0 回答 0