I have a Spry.Data.XMLDataSet I want a row to be added in the 1st location and also get highlighted when it appears in my table.
var ds1 = new Spry.Data.XMLDataSet("/xml/data.xml", "rows/row");
Here is the data.xml
<?xml version="1.0" encoding="UTF-8"?>
<rows>
<row id="a">
<name>Abhishek</name>
<host>windows_Abhishek</host>
</row>
<row id="b">
<name>Rahul</name>
<host>windows_Rahul</host>
</row>
</rows>
This is what I am doing after a button click
Note: Refferred from here http://forums.adobe.com/message/184422#184422
But it does not seem to work, can somebody help?
function addRow()
{
var newRow = new Array();
var nextID = ds1.getRowCount();
newRow['ds_RowID'] = nextID;
newRow['id'] = "c";
newRow['name'] = "CJ";
newRow['desc'] = "windows_CJ";
ds1.dataHash[newRow['ds_RowID']] = newRow;
ds1.data.push( newRow);
ds1.setCurrentRow(newRow.ds_RowID);
Spry.Data.updateRegion(ds1);
}
I managed to make it work by calling a sort
ds1.sort('name','descending');
ds1.setCurrentRow(newRow.ds_RowID);
It solved the problem