2012-06-19 74 views
3

我有下面的示例應用程序,我試圖爲sencha觸摸實現分頁功能,但我在設置頁面大小時遇到​​問題,而且當我點擊加載時,更多的舊數據正在重複清單,請問我可以知道我哪裏出錯了?爲sencha觸摸列表實現分頁

Ext.define("WEB.view.SearchView", { 
    extend: 'Ext.dataview.List', 
    xtype: 'SearchView', 
requires: [ 
     'Ext.dataview.List', 
     'Ext.data.Store', 
     'Ext.List' 
    ], 

    config: { 

    title: 'Search Results', 
    plugins: [ 
          { 
           xclass: 'Ext.plugin.ListPaging', 
           autoPaging: false, 
           loadMoreText: 'Loading...', 
           noMoreRecordsText: 'No More Records' 
          }, 
          { xclass: 'Ext.plugin.PullRefresh' } 
         ], 
     //onItemDisclosure: false, 
     store: { 

      id: 'MySearchStore', 
      autoLoad:false, 
     pageSize: 15, 
     clearOnPageLoad: false, 
       fields: [ 
        { name: "ShortDescription", type: "string" }, 
       { name: "MatchId", type: "bool" } 
       ], 
      proxy: { 
       type: 'jsonp', 
       url: 'http://Example.com', 
       reader: { 
        type: 'json', 
        rootProperty: 'd' 
       } 
      } 
     }, 
     itemTpl: new Ext.XTemplate('<tpl if="MatchId == 1">', '<p style="color: #ff9900">{BlockNo}</p><p>{ShortDescription}</p>', '</tpl>', 
      '<tpl if="MatchId == 0">', '<p >{BlockNo}</p><p>{ShortDescription}</p>', '</tpl>' 
     ) 
    } 
}); 
+0

請問您能否顯示JSON響應?那裏有鑰匙嗎? –

+0

此外,您的模型應該可能包含由後端發送的id填充的id字段。 –

回答

3

這是一個簡單的問題,但是當你開始了可能成爲瓶頸...... 設置在店裏你用什麼在服務器端分頁的pageParam ......然後,一切都應該正常工作...

注意:您的實際分頁邏輯應該是在服務器端...煎茶只提供了顯示內容在同一時間幾個手段......

Ext.define('MyApp.store.MyJsonStore', { 
extend: 'Ext.data.Store', 

config: { 
    storeId: 'MyJsonStore', 
    proxy: { 
     type: 'ajax', 
     pageParam: 'page',//This parameter needs to be modified 
     reader: { 
      type: 'json' 
     } 
    } 
} 

});