-
12 Oct 2012 12:12 AM #1
[4.1.1] Grid row selection lost upon calling record.set()
[4.1.1] Grid row selection lost upon calling record.set()
REQUIRED INFORMATION
Ext version tested:- Ext 4.1.1
- Chrome 22.0
- Firefox 16.0.1
- Safari 6.0.1
Select a row in grid panel with single selection mode, update the underlying record by calling record.set() in the select event handler, then the grid row selection will be gone, and click on that row again will not highlight it.
Steps to reproduce the problem:- Create a grid panel with single selection mode
- Listen the select event of the grid panel
- In the select event handler, update the record by calling record.set(field, value)
After updating record, the grid row selection is preserved.
The result that occurs instead:
After updating record, the grid row selection is lost.
Test Case:
Code:Ext.onReady(function() { var grid = Ext.create('Ext.grid.Panel', { store: { fields: ['id', 'value'], data: [ {id: 1, value: 'initial value'}, {id: 2, value: 'initial value'} ] }, columns: [ {text: 'id', dataIndex: 'id'}, {text: 'value', dataIndex: 'value', flex: 1} ], renderTo: Ext.getBody() }); grid.on('select', function(selModel, record, index) { // ExtJS 4.1.1 Bug: select a row, update record, selection will be lost. setTimeout(function() { record.set('value', Math.random()); }, 1000); }); });
HELPFUL INFORMATION
See this URL for live test case: http://jsfiddle.net/jaux/5LFkv/
Possible fix:
I've found this issue is because of the incorrect removal of the x-grid-row-selected class of the grid row in Ext.view.Table.onUpdate(), here is my fix:
Additional CSS used:Code:--- old/Table.js 2012-10-12 03:50:30.000000000 -0400 +++ new/Table.js 2012-10-12 03:51:09.000000000 -0400 @@ -700,8 +700,8 @@ index, newRow, newAttrs, attLen, i, attName, oldRow, oldRowDom, oldCells, newCells, len, i, - columns, overItemCls, - isHovered, row, + columns, + row, // See if an editing plugin is active. isEditing = me.editingPlugin && me.editingPlugin.editing; @@ -709,7 +709,6 @@ index = me.store.indexOf(record); columns = me.headerCt.getGridColumns(); - overItemCls = me.overItemCls; // If we have columns which may *need* updating (think lockable grid child with all columns either locked or unlocked) // and the changed record is within our view, then update the view @@ -718,7 +717,6 @@ oldRow = me.all.item(index); if (oldRow) { oldRowDom = oldRow.dom; - isHovered = oldRow.hasCls(overItemCls); // Copy new row attributes across. Use IE-specific method if possible. if (oldRowDom.mergeAttributes) { @@ -728,16 +726,12 @@ attLen = newAttrs.length; for (i = 0; i < attLen; i++) { attName = newAttrs[i].name; - if (attName !== 'id') { + if (attName !== 'id' && attName !== 'class') { oldRowDom.setAttribute(attName, newAttrs[i].value); } } } - if (isHovered) { - oldRow.addCls(overItemCls); - } - // Replace changed cells in the existing row structure with the new version from the rendered row. oldCells = oldRow.query(me.cellSelector); newCells = Ext.fly(newRow).query(me.cellSelector);- only default ext-all.css
- OSX 10.8
- Fedora 14
-
12 Oct 2012 6:44 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 436
Can reproduce in 4.1.1 but not in 4.1.2 so this has been fixed already.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
15 Oct 2012 3:42 AM #3
I also experience this issue in 4.1.1. When will 4.1.2 be available for the rest of us none support subscribers?
Tnx
Rickard Claeson
Looks like we cannot reproduce this. Please provide another test case to reproduce this issue.


Reply With Quote