3.0 beta 2

How do I best remove a row?

Hi,

I'm trying to learn how to delete rows from the grid. Here is my code...

function remove_row() {
if (obj.getSelectionProperty("index") != -1) {
data.splice(obj.getSelectionProperty("index"), 1);
num_rows--;
obj.setRowProperty("count", num_rows);
obj.setDataProperty("text", function(i, j){return data[i][j]});
obj.refresh();
}
}

This works fine, until the row order gets changed by sorting. Then the line with the call to setDataProperty returns an error that "data[..] is null or not an object." I'm not sure what to do, any help would be greatly appreciated. Thanks.

Sincerely,
Mike
someguy
January 27,
I don't know if this is going to make a big difference, but the official way to set the text of each cell is setCellText(arrayName). So if you change your setDataProperty and setRowProperty calls to:

obj.setCellText(data);
obj.setRowCount(num_rows);


That might clear things up a bit.
I did assume that since you posted this with a 2.0 classification that you are using 2.0. If you are using 1.0 then disregard my info above.
Jim Hunter
January 27,
I figure it out how to solve in version 1.0.
Put this before refresh();

obj.setRowCount(num_rows)
obj.setSelectionProperty("values", new Array());
obj.setRowProperty("value", function(i){return i});
obj.refresh();

Hope it helps.
flashsnake
August 1,

This topic is archived.

See also:


Back to support forum

Search

Version 2

Looking for AW 2.6 ?
The old site is here.