var itemsPerPage = 10; // set the number of items you want per page
var data = {
"success" : true,
"users" : [{
"id" : 1,
"name" : 'ed',
"email" : "[email protected]"
}, {
"id" : 2,
"name" : 'Tommy',
"email" : "[email protected]"
},
{
"id" : 3,
"name" : 'Tommy',
"email" : "[email protected]"
},
{
"id" : 4,
"name" : 'Tommy',
"email" : "[email protected]"
},
{
"id" : 5,
"name" : 'Tommy',
"email" : "[email protected]"
},
{
"id" : 44,
"name" : '1',
"email" : "[email protected]"
},
{
"id" : 45,
"name" : '2',
"email" : "[email protected]"
},
{
"id" : 11,
"name" : 'Ed',
"email" : "[email protected]"
}, {
"id" : 12,
"name" : 'apple',
"email" : "[email protected]"
},
{
"id" : 13,
"name" : 'Apple',
"email" : "[email protected]"
},
{
"id" : 14,
"name" : 'Tommy',
"email" : "[email protected]"
},
{
"id" : 15,
"name" : 'tommy',
"email" : "[email protected]"
},
{
"id" : 21,
"name" : 'Ed',
"email" : "[email protected]"
}, {
"id" : 22,
"name" : 'Tommy',
"email" : "[email protected]"
},
{
"id" : 23,
"name" : 'Tommy',
"email" : "[email protected]"
},
{
"id" : 24,
"name" : 'Tommy',
"email" : "[email protected]"
},
{
"id" : 25,
"name" : 'Tommy',
"email" : "[email protected]"
},
]
}
Ext.apply(Ext.data.SortTypes, {
asPerson : function (name) {
// expects an object with a first and last name property
console.log("Test");
return name.toUpperCase() + name.toLowerCase();
}
});
var store = Ext.create('Ext.data.Store', {
autoLoad : true,
fields : [{
name : 'name',
sortType : 'asPerson'
}, {
name : 'email'
// sortType set to asFloat
}
],
pageSize : itemsPerPage, // items per page
data : data,
proxy : {
type : 'memory',
enablePaging : true,
reader : {
type : 'json',
root : 'users',
successProperty : 'success'
}
},
sorters : [{
property : 'name',
direction : 'ASC'
}
],
});
//Ext.Ajax.request({
// loadMask: true,
// url: 'app/data/users.json',
//
// success: function(resp) {
// // resp is the XmlHttpRequest object
// var options = resp.responseText;
//
//
//
// store.loadData(options);
// }
//});
//
//
Ext.define('AM.view.user.list', {
extend : 'Ext.grid.Panel',
alias : 'widget.userlist',
title : 'All Users',
initComponent : function() {
Ext.create('Ext.grid.Panel', {
title : 'My Test Demo',
store : store,
columns : [{
header : 'ID',
dataIndex : 'id'
}, {
header : 'Name',
dataIndex : 'name'
}, {
header : 'Email',
dataIndex : 'email',
flex : 1
}
],
width : 350,
height : 280,
dockedItems : [{
xtype : 'pagingtoolbar',
store : store, // same store GridPanel is using
dock : 'bottom',
displayInfo : true,
pageSize : 5,
}
],
renderTo : Ext.getBody()
});
this.callParent(arguments);
}
});
모델의 외관은 어떻습니까? – JesseRules