'Ext.form.*',
'Ext.layout.container.Column',
'Ext.tab.Panel',
'Ext.grid.*',
'Ext.data.*',
'Ext.util.*',
'Ext.state.*'
]);
Ext.define('Writer.Person', {
extend: 'Ext.data.Model',
fields: [
{name: 'id', type: 'float'},
{name: 'name', type: 'string'},
{name: 'price', type: 'float'}
]
});
var store = Ext.create('Ext.data.Store', {
model: 'Writer.Person',
autoLoad: true,
autoSync: true,
proxy: {
type: 'ajax',
api: {
read: 'php/newgrid.php?mytype=list',
create: 'app.php/users/create',
update: 'app.php/users/update',
destroy: 'http://ift.tt/1jbIROx'
},
reader: {
type: 'json',
successProperty: 'success',
root: 'users',
messageProperty: 'message'
},
writer: {
type: 'json',
writeAllFields: false,
root: 'users'
},
listeners: {
exception: function(proxy, response, operation){
Ext.MessageBox.show({
title: 'REMOTE EXCEPTION',
msg: operation.getError(),
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
}
}
},
listeners: {
write: function(proxy, operation){
if (operation.action == 'destroy') {
//main.child('#form').setActiveRecord(null);
}
Ext.example.msg(operation.action, operation.resultSet.message);
}
}
});
var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
clicksToMoveEditor: 1,
autoCancel: false
});
Ext.define('MyDesktop.test', {
extend: 'Ext.ux.desktop.Module',
id:'grid-test',
init : function(){
this.launcher = {
text: 'TEST GRID 2',
iconCls:'icon-grid'
};
},
createWindow : function(){
var desktop = this.app.getDesktop();
var win = desktop.getWindow('grid-test');
if(!win){
win = desktop.createWindow({
//--
i want to add grid in this
//--
});
}
return win;
}
});
var grid = Ext.create('Ext.grid.Panel', {
store: store,
columns: [{
header: 'Name',
dataIndex: 'name',
flex: 1,
editor: {
// defaults to textfield if no xtype is supplied
allowBlank: false
}
}, {
header: 'Price',
dataIndex: 'price',
width: 160,
editor: {
allowBlank: false
}
}],
renderTo: 'editor-grid',
width: 600,
height: 400,
title: 'Employee Salaries',
frame: true,
tbar: [{
text: 'Add Employee',
iconCls: 'employee-add',
handler : function() {
rowEditing.cancelEdit();
// Create a model instance
var r = Ext.create('Employee', {
name: 'input name',
peice: Ext.Date.clearTime(new Date()),
active: true
});
store.insert(0, r);
rowEditing.startEdit(0, 0);
}
}, {
itemId: 'removeEmployee',
text: 'Remove Employee',
iconCls: 'employee-remove',
handler: function() {
var sm = grid.getSelectionModel();
rowEditing.cancelEdit();
store.remove(sm.getSelection());
if (store.getCount() > 0) {
sm.select(0);
}
},
disabled: true
}],
plugins: [rowEditing],
listeners: {
'selectionchange': function(view, records) {
grid.down('#removeEmployee').setDisabled(!records.length);
}
}
});
Aucun commentaire:
Enregistrer un commentaire