Search code examples
javascripthtmlspry

Refresh a spry region after addition of a tuple in Spry.Data.XMLDataSet


Here is the dataset

var ds1 = new Spry.Data.XMLDataSet("/xml/data.xml", "rows/row"); 
var pv1 = new Spry.Data.PagedView( ds1 ,{ pageSize: 10 , forceFullPages:true, useZeroBasedIndexes:true});
var pvInfo = pv1.getPagingInfo();

Here is the addition of the tupple

function addRow()
{
var newRow = new Array();
var nextID = ds1.getRowCount(); 

newRow['ds_RowID'] = nextID; 
newRow['name'] = "Abhishek"; 
newRow['country'] = "India";

ds1.dataHash[newRow['ds_RowID']] = newRow; 
ds1.data.push(newRow); 

ds1.setCurrentRow(newRow.ds_RowID); 
Spry.Data.updateRegion(ds1); 
Spry.Data.updateRegion(pv1);

ds1.loadData();
ps1.loadData();
}

My ds1 is getting updated but how will i refresh my div with spry region pv1 that has a table to display all my rows. Please help.


Solution

  • I managed to make it work by calling a sort

    ds1.sort('name','descending'); 
    ds1.setCurrentRow(newRow.ds_RowID);
    

    It solved the problem