PDA

View Full Version : Custom GridPanel restFull store problem



muratyildiz
6 Oct 2010, 5:12 AM
I have a custom grid for restfull store. I want to edit record on custom grid like ext restfull store example. But not shown column editor's. There is no problem on datastore. Can you help me?
Plugin:


Ext.ns('JEStudio');
JEStudio.GridPanel = Ext.extend(Ext.grid.GridPanel, {
border : false,
url : null,
groupView : false,
groupField : null,
autoHeight : true,
loadMethod : 'list',
updateMethod : 'update',
deleteMethod : 'delete',
showPagingToolbar : true,
autoScroll: true,
userForm : null,
clicksToEdit: 1,
editable : false,
editor : null,
initComponent : function(config) {
var config = config||{};
this.buildConfig(config);
config.tbar = [{
text: 'Yeni Kay?t',
iconCls: 'silk-add',
handler: this.onAdd,
scope: this
}, '-', {
text: 'Sil',
iconCls: 'silk-delete',
handler: this.onDelete,
scope: this
}, '-',
{
text: 'Kaydet',
iconCls: 'silk-save',
handler: this.onSave,
scope: this
}, '-'];
if (this.editable) {
this.plugins = [new Ext.ux.RowEditor()];
}
// apply config
Ext.apply(this, Ext.apply(this.initialConfig, config));
JEStudio.GridPanel.superclass.initComponent.apply(this, arguments);
} // eo function initComponent
,
buildConfig : function(config) {
this.buildColumns(config);
this.buildPlugins(config);
this.buildTbar(config);
this.buildBbar(config);
//
} // eo function buildConfig
,
buildColumns : function(config) {
config.columns = undefined;
} // eo function buildColumns
,
getReaderFields : function() {
var flds = [];
var columns = this.getColumnModel().getColumnsBy(function(c) {
if (c.mapping) {
flds[flds.length] = {
name : c.dataIndex,
mapping : c.dataIndex
};
}
});
return flds;
},
rowclick : function(g, index, ev) {
if (this.userForm) {
var rec = this.store.getAt(index);
Ext.getCmp(this.userForm).getForm().loadRecord(rec);
}
},// eo function rowClick
buildPlugins : function(config) {
config.plugins = undefined;
} // eo function buildPlugins
,
buildTbar : function(config) {
config.tbar = undefined;
} // eo function buildTbar
,
buildBbar : function(config) {
config.bbar = undefined;

}, // eo function buildBbar
onAdd : function(btn, ev) {
var u = new this.store.recordType();
this.stopEditing();
this.store.insert(0, u);
this.startEditing(0, 1);
},//eo function onAdd
onSave : function(btn, ev) {

this.store.save();
}, //eo function onSave

onDelete : function(btn, ev) {
var self = this;
var selected_rows = self.getSelectionModel().getSelections();
if(selected_rows.length > 0) {
var id = '';
var i = 0;
for(i=0; i<selected_rows.length; i++) {
id += selected_rows[i].get(self.store.idProperty);
if(i < (selected_rows.length - 1)) {
id += ',';
}
}
//alert(id);

Ext.MessageBox.confirm('Dikkat', 'Seçili kay?t veya kay?tlar silinecektir. Emin misiniz?', function (btn, text) {
if (btn=='yes') {
//alert(self.url+'!'+self.deleteMethod);
Ext.Ajax.request({
url : self.url+'!'+self.deleteMethod,
params : {
id: id
},
method: 'POST',
success: function (results, request ) {
//Ext.MessageBox.hide();
//self.getStore().reload();
var i = 0;
for(i=0; i<selected_rows.length; i++) {
self.store.remove(selected_rows[i]); }
}
});
}
});

} else {
Ext.MessageBox.alert('Uyar?', 'Silmek için herhangi bir kay?t seçilmemi?. Silmek için listeden kay?t veya kay?tlar?(CTRL bas?l? tutarak) öncelikle seçmelisiniz.');
}
},//eo function onDelete
onRender : function() {
if (this.autoLoad)
this.store.load();
JEStudio.GridPanel.superclass.onRender.apply(this, arguments);

} // eo function onRender
,
loadexception : function(obj, options, response, e) {
var errors = Ext.decode(response.responseText);
Ext.jes.showErrorsStore(errors);
}// eo function loadexception
,
load : function() {
this.load();
}// eo function load
});

Ext.reg('jesgrid', JEStudio.GridPanel);
Sample Code : not work




var grid = new JEStudio.GridPanel({
url : '/jestudio/yetki/LogAction',
autoLoad : false,
store : storeR,
userForm :'nameForm',
autoHeight:false,
height : 400,
editable : true,
buildColumns:function(cfg) {
cfg.columns = [
{ header: 'Firt Name',dataIndex:'firstName',width:150, editor: new Ext.form.TextField({})},
{ header: 'Last Name',dataIndex:'lastName',width:150},
{ header: 'Mid Name',dataIndex:'middleName',width:150, editor: new Ext.form.TextField({})},
{ header: 'Date',dataIndex:'dob',width:150,type:'date',format:'d/m/Y',editor: new Ext.form.DateField({format:'d/m/Y'})}
];
}
,buildBbar:function(cfg) {
cfg.bbar = [new JEStudio.PagingToolbar({store:storeR,pageSize :20})];
}
});
This code is work.(same datastore)


var grid4 = new Ext.grid.GridPanel({
url : '/jestudio/yetki/LogAction',
autoLoad : false,
store : storeR,
autoHeight:false,
height : 400,
columns : [
{ header: 'Firt Name',dataIndex:'firstName',width:150, editor: new Ext.form.TextField({})},
{ header: 'Last Name',dataIndex:'lastName',width:150},
{ header: 'Mid Name',dataIndex:'middleName',width:150, editor: new Ext.form.TextField({})},
{ header: 'Date',dataIndex:'dob',width:150,type:'date',format:'d/m/Y',editor: new Ext.form.DateField({format:'d/m/Y'})}
],
bbar : [new JEStudio.PagingToolbar({store:storeR,pageSize :20})],
plugins :[editor1]
});

Condor
6 Oct 2010, 5:29 AM
I don't see a buildPlugins method that sets this.plugins to [editor1]...

muratyildiz
6 Oct 2010, 5:53 AM
on custom grid init :



....
if (this.editable) {
this.plugins = [new Ext.ux.RowEditor()];
}
....

muratyildiz
6 Oct 2010, 6:00 AM
Thanks. Problem solved. Plugins problem . Your are right. I added buildPlugins method then work.


var grid = new JEStudio.GridPanel({
url : '/jestudio/yetki/LogAction',
autoLoad : false,
store : storeR,
userForm :'nameForm',
autoHeight:false,
height : 400,
editable : true,
buildColumns:function(cfg) {
cfg.columns = [
{ header: 'Firt Name',dataIndex:'firstName',width:150, editor: new Ext.form.TextField({})},
{ header: 'Last Name',dataIndex:'lastName',width:150},
{ header: 'Mid Name',dataIndex:'middleName',width:150, editor: new Ext.form.TextField({})},
{ header: 'Date',dataIndex:'dob',width:150,type:'date',format:'d/m/Y',editor: new Ext.form.DateField({format:'d/m/Y'})}
];
}
,buildBbar:function(cfg) {
cfg.bbar = [new JEStudio.PagingToolbar({store:storeR,pageSize :20}),'-','->','Deneme'];
}
,buildPlugins:function(cfg) {
cfg.plugins = [new JEStudio.RowEditor()];
}
});