function addRow()
{
var rowData = ["", "", "", "", ""];
// Save existing sort values
var array = obj.getRowProperty("values");
// Add an extra row
myData.push(rowData);
// re-initialize the data values
obj.setDataProperty("count", myData.length);
// Reset sort property (does not re-sort propertly if this is not done
obj.setSortProperty("index", -1);
// Put back the sort values (new row stays at bottom of grid)
array.push(myData.length-1);
obj.setRowProperty("values", array);
// refresh the grid
obj.refresh();
}
function removeRow()
{
var index = obj.getProperty("selection/index");
if (index != -1 && confirm("Are you sure?"))
{
// Get existing sort values, re-number then deleted element
var array = obj.getRowProperty("values");
var splice_point=-2;
var new_selected_row=-1;
for (var i=0;i index)
array[i]--;
if (splice_point == i-1)
new_selected_row=array[i];
}
// Check the values are ok just to be sure
if (splice_point >= 0)
array.splice(splice_point,1);
if (new_selected_row == -1)
new_selected_row=array[array.length-1];
myData.splice(index,1);
obj.setRowProperty("count", myData.length);
// re-initialize the data values
obj.setDataProperty("count", myData.length);
// Put back the sort values
obj.setRowProperty("values", array);
obj.setProperty("selection/index",new_selected_row);
// refresh the grid
obj.refresh();
}
}