PDA

View Full Version : How to move a column in a grid?



grigory666
7 Nov 2009, 12:30 PM
I try to create in my grid a button, which will move the column. Here is my code:

var cm = new Ext.grid.ColumnModel({
columns:[{
id: 'variable',
header: 'variable',
dataIndex: 'variable'
},
{
id: 'value',
header: 'value',
dataIndex: 'value'

}],
defaults:
{
sortable: true,
menuDisabled: false,
width: 220
}

});


var grid = new Ext.grid.EditorGridPanel({
store: myStore,
cm:cm,
tbar:
[
{text: 'Up',
handler: function() {
if(grid.getSelectionModel().selection != null)
{
var row = grid.getSelectionModel().selection.cell[0] ;
cm.moveColumn(row, row-1);
}
}
}

]
,
autoExpandColumn: 'value',
height:250
}); But there is an error in firebug, after pressing button 'Up':

this.config[col] is undefined
return this.config[col].dataIndex;\n ext-all-debug.js (string 62917)
How to move a column correctly?

grigory666
7 Nov 2009, 11:51 PM
Sorry, I found my mistake: I want to move a row, but I move a column. But I didnít found how to move a row yet(

Jaitsu
8 Nov 2009, 3:27 AM
Your data is sourced from a data store, which will be ordered on a particular attribute. It depends on how you're ordering your data.

Why do you want to move a row?