Zakaroonikov
08-28-2007, 05:52 PM
I have changed the following in the UIView class from
gridDeleteDocumentSuccess: function(o) {
//alert("The document was successfully deleted.");
var row = o.argument;
var ds = this.grid.getDataSource();
var sm = this.grid.selModel;
var rowIndex = ds.indexOf(row);
if (rowIndex == ds.data.length) {
sm.selectRow(rowIndex);
} else {
sm.selectRow(rowIndex+1);
}
ds.remove(row);
},
To
/**
* Remove the row from the grid/data store after a successful AJAX document delete operation
* @param {Object} Ajax result set containing index of row to remove
*/
gridDeleteDocumentSuccess: function(o) {
//alert("The document was successfully deleted.");
var rowIndex = o.argument;
var ds = this.grid.getDataSource();
var sm = this.grid.selModel;
var row = ds.getAt(rowIndex);
if (rowIndex == ds.data.length) {
sm.selectRow(rowIndex);
} else {
sm.selectRow(rowIndex+1);
}
ds.remove(row);
},
As the argumnent being passed on a successful deletion is the index and not the actual row so instead I have to use getAt(index) to get the actual record to remove.
gridDeleteDocumentSuccess: function(o) {
//alert("The document was successfully deleted.");
var row = o.argument;
var ds = this.grid.getDataSource();
var sm = this.grid.selModel;
var rowIndex = ds.indexOf(row);
if (rowIndex == ds.data.length) {
sm.selectRow(rowIndex);
} else {
sm.selectRow(rowIndex+1);
}
ds.remove(row);
},
To
/**
* Remove the row from the grid/data store after a successful AJAX document delete operation
* @param {Object} Ajax result set containing index of row to remove
*/
gridDeleteDocumentSuccess: function(o) {
//alert("The document was successfully deleted.");
var rowIndex = o.argument;
var ds = this.grid.getDataSource();
var sm = this.grid.selModel;
var row = ds.getAt(rowIndex);
if (rowIndex == ds.data.length) {
sm.selectRow(rowIndex);
} else {
sm.selectRow(rowIndex+1);
}
ds.remove(row);
},
As the argumnent being passed on a successful deletion is the index and not the actual row so instead I have to use getAt(index) to get the actual record to remove.