2014-09-10 57 views
0

我想在ExtJS 5中實現一個帶分頁工具欄的網格。我得到數據的第一頁,但是當推進網格時不會更新新數據。ExtJS Paging Grid不會前進

它似乎沒有更新data.asp頁面的新的起始值來更新我的記錄集的.AbsolutePosition屬性。所以網格不斷顯示第一頁的信息。

我的代碼如下...

var gridStore = Ext.create('Ext.data.JSonStore', { 
     autoLoad: false, 
     fields: [ 
      {name: 'field1', type: 'int'}, 
      {name: 'field2', type: 'int'} 
     ], 
     pageSize: 25, 
     proxy: { 
       type: 'ajax', 
       url: 'Data.asp', 
       reader: { 
        type: 'json', 
        rootProperty: 'rows', 
        totalProperty: 'totalCount', 
       } 
     } 
    }); 

    gridStore.load({ 
     params: { 
       start: 0, 
       limit: 25 
     } 
    }); 

    grid = Ext.create('Ext.grid.Panel', { 
     renderTo: 'grid-Spec', 
     store: gridStore, 
     columns: [ 
      {text: 'Field 1', width: 10, sortable: true, dataIndex: 'field1'}, 
      {text: 'Field 2', width: 10, sortable: true, dataIndex: 'field2'} 
     ], 
     height: 100, 
     width: 20, 
     selModel: { mode: 'SINGLE' }, 
     dockedItems: [{ 
      xtype: 'pagingtoolbar', 
      store: gridStore, 
      dock: 'bottom', 
      displayInfo: true 
     }] 
    }); 

回答

0

你的代碼中有一些拼寫錯誤,但總的來說它看起來OK。

問題可能出在服務器端 - 使用ajax代理時,必須在服務器端實現分頁。如果您在服務器端實施了分頁,請使用一些開發人員工具(例如在Chrome中)並查看頁碼是否正確提交。您應該在地址中看到起始/頁碼(例如:http://fiddle.jshell.net/echo/json/?_dc=1410854522824&page=2&start=5&limit=5)。

我做了小提琴:http://jsfiddle.net/seur2aLx/9/你可以將你的代碼與我的進行比較(注意Ext.ux.data.reader.Json只能僞造一些網格數據)。