tof
1 Feb 2007, 4:54 AM
There is a bug in JSONDataModel, the "loadData" function does not take care of insertIndex.
The code is pretty much the same as XMLDataModel, so I copied it from one to another, and it does work:
if(keepExisting !== true){
this.removeAll();
}
this.addRows(rowData);
if(typeof callback == 'function'){
callback(this, true);
}
this.fireLoadEvent();
Replaced by :
if(keepExisting !== true){
YAHOO.ext.grid.JSONDataModel.superclass.removeAll.call(this);
}
if(typeof insertIndex != 'number'){
insertIndex = this.getRowCount();
}
YAHOO.ext.grid.JSONDataModel.superclass.insertRows.call(this, insertIndex, rowData);
if(typeof callback == 'function'){
callback(this, true);
}
this.fireLoadEvent();
And add a fourth argument "insertedIndex" for loadData in JSONDataModel.
Note:
My goal was to reload a row, like this :
dm.reloadId(id, url);
So I :
get the index : idx = grid.getRowById(id).roxIndex
remove the row : dm.removeRow(idx)
insert the row : dm.load(url, null, null, idx)
Could this be native in LoadableDataModel ?
--
Tof
The code is pretty much the same as XMLDataModel, so I copied it from one to another, and it does work:
if(keepExisting !== true){
this.removeAll();
}
this.addRows(rowData);
if(typeof callback == 'function'){
callback(this, true);
}
this.fireLoadEvent();
Replaced by :
if(keepExisting !== true){
YAHOO.ext.grid.JSONDataModel.superclass.removeAll.call(this);
}
if(typeof insertIndex != 'number'){
insertIndex = this.getRowCount();
}
YAHOO.ext.grid.JSONDataModel.superclass.insertRows.call(this, insertIndex, rowData);
if(typeof callback == 'function'){
callback(this, true);
}
this.fireLoadEvent();
And add a fourth argument "insertedIndex" for loadData in JSONDataModel.
Note:
My goal was to reload a row, like this :
dm.reloadId(id, url);
So I :
get the index : idx = grid.getRowById(id).roxIndex
remove the row : dm.removeRow(idx)
insert the row : dm.load(url, null, null, idx)
Could this be native in LoadableDataModel ?
--
Tof