:: Forum >>
Sorting issues
Hi! Me again.
I finish some functions to add, remove, update and "undo". Here is the delete one.
function deleteRow(dataGrid, myArray, index, lastActionPerformed){
if (confirm("You wanna delete me?")) {
delRow = myArray.splice(index,1);
dataGrid.setRowProperty("count", myArray.length);
dataGrid.refresh();
alert ("Deleted row: " + delRow );
return new lastAction("delete",index,delRow[0]);
} else {
return lastActionPerformed;
}
}
lastActionPerformed is a lastAction object (contains the info to undo), dataGrid is obj, myArray is myData and index is index :p
All work fine, but if i sort the grid the function stops working and the message " myData is null or isn't an object..." appears... :(
The index of row change when i sort?
Is needed a index (like in a database) to keep track of the rows and delete them searching in it?
I'm doing something wrong?
Please help.
Thanks.
Basking Rootwalla
Tuesday, May 11, 2004
I am having the same problem can some one help us?
Shahzad
Thursday, June 10, 2004
I am having the same problem:
- if column sorting has been applied to the grid, changing row/count to a lower value is a problem.
- if the grid is not sorted (just natural display order) there is no problem changing row/count
I got around this by setting row/values to the correct [0,1,2...], but that is just a workaround.
Maybe Alex has a hint about this?
Thanks
Claude
Friday, July 9, 2004
Any know fix?
Sudhaker Raj
Wednesday, July 14, 2004
proudly presenting a solution...:
// keeps sorting the way it was after deleting a row...
oldRowValues=obj.getRowValues();
for (rv=0;rv<oldRowValues.length;rv++) {
if (oldRowValues[rv]==deleteIndex) oldRowValues.splice(rv,1);
if (oldRowValues[rv]>deleteIndex) oldRowValues[rv]--;
}
myGrid.splice(deleteIndex,1);
obj.setProperty("row/count",myGrid.length);
obj.setRowValues(oldRowValues);
obj.refresh();
// if you need the grid stay on its scrollposition after deleting:
// found somewhere in this forum...
var scrollbars = obj.getTemplate("layout").getContent("scrollbars");
var x = scrollbars.element().scrollLeft;
var y = scrollbars.element().scrollTop;
obj.refresh();
window.setTimeout(function(){
scrollbars.element().scrollLeft = x;
scrollbars.element().scrollTop = y;
}, 0 );
yves
Monday, November 1, 2004
Sudhaker Raj
Monday, November 1, 2004
This topic is archived.
Back to support forum
Forum search