Code:
Ext.require([
'Ext.grid.*',
'Ext.window.Window',
'Ext.container.Viewport',
'Ext.layout.container.Border',
'Ext.state.*',
'Ext.data.*',
'Ext.grid.feature.Summary'
]);
Ext.onReady(function(){
// setup the state provider, all state information will be saved to a cookie
Ext.state.Manager.setProvider(Ext.create('Ext.state.CookieProvider'));
Ext.create('Ext.container.Viewport', {
layout: {
type: 'border',
padding: '5'
},
items: [{
region: 'center',
stateful: true,
stateId: 'stateGridExample',
xtype: 'grid',
features: { ftype: 'summary' },
store: lesPersonnes,
columns: [{
text: 'First Name',
dataIndex: 'first'
}, {
text: 'Last Name',
dataIndex: 'last'
}, {
text: 'Age',
dataIndex: 'age',
hidden: true
}, {
flex: 1,
text: 'Review',
dataIndex: 'review',
hidden: true
}]
}]
});
});
var lesPersonnes = Ext.create('Ext.data.Store', {
model: Ext.define('Person', {
extend: 'Ext.data.Model',
fields: ['first', 'last', 'review', {
name: 'age',
type: 'int'
}]
}),
data: [{
first: 'John',
last: 'Smith',
age: 32,
review: 'Solid performance, needs to comment code more!'
}, {
first: 'Jane',
last: 'Brown',
age: 56,
review: 'Excellent worker, has written over 100000 lines of code in 3 months. Deserves promotion.'
}, {
first: 'Kevin',
last: 'Jones',
age: 25,
review: 'Insists on using one letter variable names for everything, lots of bugs introduced.'
}, {
first: 'Will',
last: 'Zhang',
age: 41,
review: 'Average. Works at the pace of a snail but always produces reliable results.'
}, {
first: 'Sarah',
last: 'Carter',
age: 23,
review: 'Only a junior, but showing a lot of promise. Coded a Javascript parser in Assembler, very neat.'
}]
});
Aucun commentaire:
Enregistrer un commentaire