PDA

View Full Version : Item in grid is deselected after record has been modified with set-method



suamikim
8 Jan 2013, 5:59 AM
Hy there,

I have a very basic example with a grid with only 1 item and a button which updates this entry with the set-method of the underlying record.

The problem is, that if the item is selected at the time the record gets updated by pressing the button, the selection gets removed and it's not possible to select it anymore afterwards.

Working example: http://jsfiddle.net/fu2Xq/2/

Ext.onReady(function() {
var personsGrid = Ext.create('Ext.grid.Panel', {
width: 150,
height: 100,
renderTo: Ext.getBody(),

store: Ext.create('Ext.data.Store', {
fields: [ 'name' ],
data: [{ name: 'Stephen' }]
}),

columns: [{ text: 'Name', dataIndex: 'name', flex: 1 }],
});

var txtField = Ext.create('Ext.form.field.Text', {
fieldLabel: 'New name',
labelWidth: 70,
width: 150,
value: 'Alex',
renderTo: Ext.getBody()
});

Ext.create('Ext.button.Button', {
text: 'Rename person',
width: 150,
renderTo: Ext.getBody(),
handler: function() {
var rec = personsGrid.getStore().getAt(0);

rec.set('name', txtField.getValue());
}
});
});

Seems like a bug to me because after reordering the name-column the selection reappears...

I'd really appreciate some comment on this!

Thanks

mitchellsimoens
10 Jan 2013, 10:08 AM
This was a bug that has been fixed in 4.1.3. The row is still selected just when the dom is updated for that one row the CSS class isn't placed on the new dom.

To get around it for 4.1.1 you can refresh the grid view after the rec.set:


personsGrid.getView().refresh();