:: Forum >>

Grid 2.02 xml refresh issues

I have picked through and tried all kinds of stuff and still can't get this right.

I am trying to refresh grid using xml data pull, I have tried 20 different ways and I just can't figure it out. Getting hugely frustrated...

I am running a check to see if any changes have occurred on db server, and if so I need to reload grid, but rember sort order, and selected row. There is a hidden row with selected ID, i need to be centered on the selected row after refresh. If no selected row I need to be at the top of grid.

Last thing i tried were variations of this:

// get sort properties
var sortColumn = obj.getSortColumn();
var sortDirection = obj.getSortDirection(sortColumn);

// somtimes this
table.setURL("admin_dashboard_xml.php?r="+Math.random());
table.request();

// refresh grid - sometimes this
obj.clearRowModel();
obj.setRowCount(table.getCount());
obj.refresh();

// reinstate sorting
if (sortColumn != -1) {
obj.sort(sortColumn, sortDirection);
}

Any help is much appreciated.... Also my other question several topics down about converting text to image on the fly is also kind of important.




Chris
Monday, March 26, 2007
Ok. This is something I found from Alex to refresh and lose flicker and show changes in red, it refreshes without flicker but the red did not work and it still loses selected row and sort. But this code adds new issue I can't check for changed data on server side anymore where before I only updated XML and refreshed with changes.... sorry for all the questions as much as i know about js, this code makes me feel like an idiot and i spend hours trying to get stuff to work.:

// create ActiveWidgets data model - XML-based table
var table = new AW.XML.Table;

// start asynchronous data retrieval
table.response1 = table.response;
table.response = function(text){
this.response1(text);
var rows = this.getCount();
if (rows != obj.getRowCount()) {
obj.setRowCount(rows);
obj.refresh();
}
var columns = obj.getColumnCount();

for (var r=0; r<rows;r++){
for (var c=0; c<columns;c++){
var v = this.getData(c, r);
if (v != obj.getCellText(c, r)){
obj.setCellText(v, c, r);
highlight(c, r);
}
}
}

function highlight(c, r){
var e = obj.getCellTemplate(c, r).element();
if (e) {
e.style.color = "red";
window.setTimeout(function(){
e.style.color = "black";
e = null;
}, 1000);
}
}

window.setTimeout(function(){
var url = "admin_dashboard_xml.php?r="+Math.random();
table.setURL(url);
table.request();
}, 10000);
}
Chris
Monday, March 26, 2007

This topic is archived.


Back to support forum

Forum search