PDA

View Full Version : Multiple issues with grid row editor



Bouki
10 Feb 2011, 7:47 AM
Hi
I'm working on a custom row editor like this one :
http://dev.sencha.com/deploy/dev/examples/grid/row-editor.html

So it works great for now, but I'm encoutering some issues while adding functionnalities so far :
- using ajax to load datas doesn't work, I tried to use the url parameter as described in the doc but firebug show me that ajax request is never done
- when reconfiguring the editor to add a column, the row editor become unusable for all old fields

The whole script is downloadable here :
http://www.multiupload.com/8PF5LJ81BK

The issue concern only file row-editor.js

For those who don't want to download code, here is the concerned code :

Ajax issue :


var store = new Ext.data.GroupingStore({
reader: new Ext.data.JsonReader({
root: 'residents',
fields: ['firstname', 'lastname', 'floor', 'door']
}),
url: 'test.json',
sortInfo: {field: 'lastname', direction: 'ASC'}
});


test.json part :


{
"residents": [
{
"id": 28,
"firstname": "david",
"lastname": "Beaudouin",
"floor": 3,
"door": "gauche"
} ,
{
"id": 1,
"firstname": "Jonathan",
"lastname": "Laurier",
"floor": 0,
"door": "droite",
"infos": [
{
"id": "2",
"id_resident": "1",
"label": "titre",
"value": "test"
},
{
"id": "1",
"id_resident": "1",
"label": "telephone",
"value": "0102030405"
}
]
}
]
}


code for adding column to the grid


function(){
editor.stopEditing();
var columns = grid.getColumnModel().getColumnsBy(function(c){
return true;
});
columns.push({
header: 'aaaaaa',
dataIndex: 'aaaaa',
width: 100,
sortable: true,
editor: {
allowBlank: true
}
});
colModel.setConfig(columns);
grid.reconfigure(store, colModel);
}

Bouki
11 Feb 2011, 3:59 AM
after somes testing I determined that calling :
grid.reconfigure(store, colModel);
causes row editor to render improperly (don't know why).

there are 2 cases :
- if store and colModel remains unchanged then the row editor is working but looks bad
- if store or colModel changed then the row editor is breaking completely

Condor
11 Feb 2011, 4:21 AM
You can't add a column that way (calling setConfig with the same config will destroy existing editors).

Have a look at my "Adding/removing fields and columns" post in the User Extensions section.

Bouki
14 Feb 2011, 12:53 AM
Hi
After viewing your post, I tried your solution
However it requires somes adaptations to work with row editor
when trying to add more than 1 column, row editor is broken
also when adding only 1 column, row editor doesn't make it editable

here's the code I've used :



handler: function() {
editor.stopEditing();
Ext.Msg.prompt('Field', 'Enter field name', function(btn, text){
if (btn == 'ok'){
grid.addColumn({name: text, type: 'string'});
}
});
}

Condor
17 Feb 2011, 2:18 AM
RowEditor doesn't handle column modifications very well. IIRC this has already been reports in the Bugs section.