3.2.0

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
May 11,
I am having the same problem can some one help us?
Shahzad
June 10,
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
July 9,

Any know fix?
Sudhaker Raj
July 14,
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
November 1,
This will also bump after sorting ;-)

Check this - http://thej2ee.com/x2/modules/newbb/viewtopic.php?topic_id=1&forum=4
Sudhaker Raj
November 1,

This topic is archived.

See also:


Back to support forum