1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
| var store;
var grid;
Ext.onReady(function(){
Ext.tip.QuickTipManager.init();
Ext.define('ressources', {
extend: 'Ext.data.Model',
fields: [
{name: 'id', type: 'number'}, 'name', 'description'
]
});
// create the Data Store
store = Ext.create('Ext.data.Store', {
pageSize: <?php echo $this->pageSize; ?>,
model: 'ressources',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/gestion/acces/ajaxressources/application/<?php echo $this->application; ?>',
reader: {
root: 'rows',
totalProperty: 'count'
}
},
sorters: [{
property: 'name',
direction: 'ASC'
}]
});
grid = Ext.create('Ext.grid.Panel', {
store: Ext.data.StoreManager.lookup(store),
disableSelection: true,
loadMask: {showMask: true, msg: 'Chargement en cours...'},
columns:[{
text: "id",
xtype: 'numbercolumn',
hidden: true
},{
text: "Nom",
dataIndex: 'name',
width: '10%',
sortable: true,
editor: {
xtype: 'textfield',
allowBlank: false
}
},{
text: "Description",
dataIndex: 'description',
width: '90%',
sortable: true,
editor: {
xtype: 'textfield',
allowBlank: false
}
}],
selType: 'rowmodel',
plugins: [
Ext.create('Ext.grid.plugin.RowEditing', {
clicksToEdit: 1
})
],
// paging bar on the bottom
bbar: Ext.create('Ext.PagingToolbar', {
store: store,
displayInfo: true,
displayMsg: 'Affichage des ressources {0} - {1} sur {2}',
emptyMsg: "Pas de ressources à afficher",
}),
renderTo: 'listeRessources'
});
store.load();
grid.on('validateedit', function(editor, e) {
Ext.Ajax.request({
url:'/gestion/acces/ajaxmodifressource',
params:{
ressourceId: e.record.data.id,
ressourceName: e.record.data.name,
ressourceDesc: e.record.data.description
},
});
});
}); |
Partager