PDA

View Full Version : reconfigure editor grid



Richie1985
4 Jul 2013, 11:34 PM
hi,

is use this to reconfigure my grid:


function modelFactory(name,fields){
model = {
extend: 'Ext.data.Model',
fields: fields
};
eval("Ext.define('"+name+"',"+Ext.encode(model)+");");
}

Ext.Ajax.request({
url: 'data/data_edit.php?action=getColumns&campaign_id='+dataPanel.getSelectionModel().getSelection()[0].get('campaign_id'),
success: function(response){
var data = Ext.decode(response.responseText);
console.log(data);

modelFactory('data_edit',data.fielddata);
var store = Ext.create('Ext.data.JsonStore', {
autoLoad: true,
model: 'data_edit',
proxy: {
type: 'ajax',
api: {
read : 'data/data_edit.php?action=get&campaign_id='+dataPanel.getSelectionModel().getSelection()[0].get('campaign_id'),
update: 'data/data_edit.php?action=set&campaign_id='+dataPanel.getSelectionModel().getSelection()[0].get('campaign_id'),
},
reader: {
type: 'json',
root: 'data_edit'
} ,extraParams: {
action: 'get'
}
}
});
console.log(data.columndata);
data_edit_Panel.reconfigure (store, data.columndata);
}
});




it works well, but how can i get this dynamic columns editable?

here is the source from server:



echo json_encode(
array(
'columndata' => array(
array('id' => 'id', 'header' => 'ID', 'width' => 30, 'sortable' => true, 'dataIndex' => 'id'),
array('header' => 'Name', 'width' => 100, 'dataIndex' => 'name'),
array('header' => 'Position', 'width' => 100, 'dataIndex' => 'position'),
array('header' => 'Ambition', 'width' => 250, 'dataIndex' => 'ambition')
),
'fielddata' => array(
array('name' => 'id', 'type' => 'int'),
array('name' => 'name'),
array('name' => 'position'),
array('name' => 'ambition')
),
'values' => array(
array(1,'Monkey D Luffy','Captain','I will become the pirate king'),
array(2,'Roronoa Zoro','Swordman','Become the greatest swordman'),
array(3,'Sanji','Cook','Find all blue'),
array(4,'Usopp','Sniper','Become the greatest warrior'),
array(5,'Nami','Navigator','Draw map of the world')
)
)
);

slemmon
8 Jul 2013, 11:09 AM
You're wanting editors on your cells / columns like in the example at the top of the API doc here:
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.grid.plugin.CellEditing