ListPage SenchaTouch 2 " ", .
, ( pageSize clearOnPageLoad), , , Senchatouch 2. SenchaTouch 1.x . SenchaTouch 2 config:
Ext.define('MessagingApp.store.MessageThreads', {
extend : 'Ext.data.Store',
requires: ['MessagingApp.model.MessageThread'],
config:
{
model: 'MessagingApp.model.MessageThread',
autoLoad: false,
clearOnPageLoad: false, // This is true by default
pageSize: 10, // This needs to be set for paging
proxy: {
type: 'jsonp',
pageParam: 'currentPage',
limitParam: 'pageSize',
url: APIURL + '/message-app-service/GetMessageThreads',
reader: {
type: 'json',
rootProperty: 'Data'
}
}
}
});
, , "load more" "no more records" :
{
xtype:'dataview',
store:'MessageThreads',
id:'threadList',
itemTpl:Ext.create('Ext.XTemplate',
'<!-- template markup goes here -->',
{
}
),
plugins:[
{
xclass:'Ext.plugin.ListPaging',
autoPaging: true,
loadMoreText: 'Loading...',
noMoreRecordsText: 'All messages loaded'
}
]
}
, , - , , , , . , " " ( №1 ). , init load , , :
Ext.define('MessagingApp.controller.Messages',
{
extend: 'Ext.app.Controller',
config:
{
views: [
'MessageThreads',
],
stores: [
'MessageThreads'
],
refs:
{
}
},
init: function() {
this.control(
{
});
var threadStore = Ext.getStore('MessageThreads');
threadStore.addBeforeListener('load', this.checkForThreadListEnd, this);
},
});
, , . , "" . , totalCount :
checkForThreadListEnd: function(store, records, isSuccessful) {
var pageSize = store.getPageSize();
var pageIndex = store.currentPage - 1;
if(isSuccessful && records.length < pageSize)
{
var totalRecords = pageIndex * pageSize + records.length;
store.setTotalCount(totalRecords);
}
else
store.setTotalCount(null);
},
"before", , , "load more" "no more records" . , "no more records" , CSS.
, .