PDA

View Full Version : me.selModel.refresh() is gone in 4.1.1 in Ext.view.Table.onUpdate()



Izhaki
29 Jul 2012, 2:49 PM
Well, not sure it's a bug...

I have a treepanel where the user changes the selected record data using a form.

When I update the record using this code:



onSaveClick: function()
{
var iForm = this.getDetailsForm().getForm(),
iRecord = iForm.getRecord(),
iValues = iForm.getValues();

iRecord.set ( iValues );
},



I've noticed that the selected tree record gets deselected with 4.1.1 while it stays selected (really gets deselected and then reselected) with 4.1;

I just wonder if I'm missing something or me.selModel.refresh() was forgotten in 4.1.1?

Here's the code for 4.1:



onUpdate : function(store, record, operation, changedFieldNames) {
var me = this,
index,
newRow, oldRow,
oldCells, newCells, len, i,
columns, overItemCls,
isHovered, row;

if (me.rendered) {

index = me.store.indexOf(record);
columns = me.headerCt.getGridColumns();
overItemCls = me.overItemCls;




if (columns.length && index > -1) {
newRow = me.bufferRender([record], index)[0];
oldRow = me.all.item(index);
isHovered = oldRow.hasCls(overItemCls);
oldRow.dom.className = newRow.className;
if(isHovered) {
oldRow.addCls(overItemCls);
}



oldCells = oldRow.query(this.cellSelector);
newCells = Ext.fly(newRow).query(this.cellSelector);
len = newCells.length;

row = oldCells[0].parentNode;
for (i = 0; i < len; i++) {

if (me.shouldUpdateCell(columns[i], changedFieldNames)) {
row.insertBefore(newCells[i], oldCells[i]);
row.removeChild(oldCells[i]);
}
}




me.selModel.refresh();
me.doStripeRows(index, index);
me.fireEvent('itemupdate', record, index, newRow);
}
}


},




And that of 4.1.1:



onUpdate : function(store, record, operation, changedFieldNames) {
var me = this,
index,
newRow, newAttrs, attLen, i, attName, oldRow, oldRowDom,
oldCells, newCells, len, i,
columns, overItemCls,
isHovered, row,

isEditing = me.editingPlugin && me.editingPlugin.editing;


if (me.viewReady) {


index = me.store.indexOf(record);
columns = me.headerCt.getGridColumns();
overItemCls = me.overItemCls;




if (columns.length && index > -1) {
newRow = me.bufferRender([record], index)[0];
oldRow = me.all.item(index);
if (oldRow) {
oldRowDom = oldRow.dom;
isHovered = oldRow.hasCls(overItemCls);



if (oldRowDom.mergeAttributes) {
oldRowDom.mergeAttributes(newRow, true);
} else {
newAttrs = newRow.attributes;
attLen = newAttrs.length;
for (i = 0; i < attLen; i++) {
attName = newAttrs[i].name;
if (attName !== 'id') {
oldRowDom.setAttribute(attName, newAttrs[i].value);
}
}
}


if (isHovered) {
oldRow.addCls(overItemCls);
}



oldCells = oldRow.query(me.cellSelector);
newCells = Ext.fly(newRow).query(me.cellSelector);
len = newCells.length;

row = oldCells[0].parentNode;
for (i = 0; i < len; i++) {


if (me.shouldUpdateCell(columns[i], changedFieldNames)) {

if (isEditing) {
Ext.fly(oldCells[i]).syncContent(newCells[i]);
}

else {
row.insertBefore(newCells[i], oldCells[i]);
row.removeChild(oldCells[i]);
}
}
}
}
me.fireEvent('itemupdate', record, index, newRow);
}
}
},