开发者

How to add a row to spry XMLDataSet?

开发者 https://www.devze.com 2023-03-02 17:21 出处:网络
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.

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>
    <开发者_如何学JAVA;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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号