PDA

View Full Version : Modify column text after moving a column



KeudOrg
21 Aug 2012, 5:20 AM
Hi,

I want to change the text of the first column of my grid when i move any column.

I add a function on the columnmove event of the grid, but it's not working. I think i have to refresh the grid, but i don't know how.

Any idea?

My panel and my grid :


Ext.onReady(function() {

var SamplePanel = Ext.extend(Ext.Panel, {
renderTo : Ext.getBody(),
autoScroll: true
});

var myPanel = new SamplePanel({
title: 'TITLE',
tbar: [
//.....
]
});

var myGrid = new Ext.grid.Panel ({
store: storeImport,
width:500,
height:400,
plugins:[new Ext.ux.grid.Imp()],
columns: [
{
dataIndex:"a",
header:"A"
}
,{
dataIndex:"b",
header:"B"
}
,{
dataIndex:"c",
header:"C"
}
,{
dataIndex:"d",
header:"D"
}
]
}
);

myPanel.add(myGrid);


});



My grid plugin


Ext.ns("Ext.ux.grid");


Ext.ux.grid.Imp = function() {


function initImp() {
//....
}


function init(component) {
grid = component;
grid.on({
afterrender:initImp,
columnmove:function(ct, column, fromIdx, toIdx, eOpts ) {
this.columns[0].text = "RRERR";
}
})
}

return {
init:init
};


};

redraid
21 Aug 2012, 5:31 AM
Try this:


Ext.create('Ext.data.Store', {
storeId:'simpsonsStore',
fields:['name', 'email', 'phone'],
data:{'items':[
{ 'name': 'Lisa', "email":"lisa@simpsons.com", "phone":"555-111-1224" },
{ 'name': 'Bart', "email":"bart@simpsons.com", "phone":"555-222-1234" },
{ 'name': 'Homer', "email":"home@simpsons.com", "phone":"555-222-1244" },
{ 'name': 'Marge', "email":"marge@simpsons.com", "phone":"555-222-1254" }
]},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
});

Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: Ext.data.StoreManager.lookup('simpsonsStore'),
columns: [
{ itemId: 'firstCol', text: 'Name', dataIndex: 'name' },
{ text: 'Email', dataIndex: 'email', flex: 1 },
{ text: 'Phone', dataIndex: 'phone' }
],
height: 200,
width: 400,
renderTo: Ext.getBody(),
listeners: {
columnmove: function (ct, column) {
var firstCol = this.down('#firstCol');

firstCol.setText('Moved!');
}
}
});

KeudOrg
21 Aug 2012, 7:01 AM
Thanks!

It's working