2012-06-19 72 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' 
     } 
    } 
} 

});