XML Table refresh causes Row deselection

I have a table that contains an XML table. If I select a row and then refresh the table the blue colored row selection disappears, but it is still the current selected row. Is there a way to maintain this after a refresh?

Do I just need to modify the table's response to accommodate this or is there a different way?

March 16,
I thought I'd provide some more details/source just in case there were any questions. Below is my table and grid code:
var tblFiles = new AW.XML.Table;
tblFiles.setParameter("random", Math.random());
tblFiles.setColumns(["name", "size"]);
var defaultResponse1 = tblFiles.response;   
    tblFiles.response = function(xml){  
    defaultResponse1.call(this, xml);  
    files = this.getCount();
    if (curFile != ""){

var grdFiles= new AW.UI.Grid;
grdFiles.setHeaderText(["File", "Size"]);
grdFiles.setCellFormat([string, string]);

When the page loads I am starting a timeout that looks at the same files.xml and counts the rows. If there is a change I refresh the tblFiles. I am also saving the currently selected row in a variable and am trying to reselect it after the refresh. Unfortunately it isn't working. Here is the code this is running every 5 seconds:
window.onload = function (){
var files = 0;
var curFile = "";
function statusFiles(thisv){
    if (thisv.readyState == 4) {
        if (thisv.status == 200) {
            var xmldoc = thisv.responseXML;
            var subNode = xmldoc.documentElement;
            nodeCount = subNode.childNodes.length;	
            if (files != nodeCount){
                files = nodeCount;
                if (grdFiles.getSelectedRows() != ""){
                    curFile = grdFiles.getSelectedRows();
                } else {
                    curFile = "";
        } else {
            alert("Error Getting Data.");

If anyone can give me any hints as to why this isnt working correctly please do. Thanks!
March 17,
By default the request includes a "this.$owner.clearSelectedModel();".
So it is needed a selection restore after any table.request() call.
March 19,

I am running the default response and then setting the selected rows. Do you think its a timing issue? Do I need add a timeout so it can finish refreshing the grid before I set the saved rowSeletion value? Thats seems like a hack way to do it.

March 19,
It could also be a timing issue, but I would try two more things first.
- declare 'files' & 'curFile' variables outside onload function.
- make tblFiles.request(); call after the custom response or even after the setCellModel.
sorry, not realy sure which one is ( so try them one by one ), and hope I am not overseeng the obvious and it could helps a few.
March 19,
'files' & 'curFile' are already declared outside. Both variable values must be maintained before and after the function is called every 5 seconds.

My solution so far is this...Previously I read the tables default response into a variable and called it before I added my own custom code to the table.response. Instead, I added the code from the default response and started commenting it out to see what the cause was. Here's what I came up with:
//var defaultResponse1 = tblFiles.response;   
tblFiles.response = function(xml){  
    //defaultResponse1.call(this, xml);  
    if (this.$owner) {

    files = this.getCount();
    if (curFile != ""){

With 'clearScrollModel', 'clearSelectedModel', 'clearSortModel', and 'clearRowModel' commented out it is all working as I had planned. Someone correct me if I am wrong, but I don't feel as though I need the SelectedModel cleared when I am just going to set them again at this time. I don't want the SortModel cleared because the grid may still be sorted a certain way. The ScrollModel I probably should set so that it is either at the top or in an area where the selected row exists. But cleared every time seems like its not what I want. RowModel I am unsure of. Anyone know what exactly this would clear?

I realize that this stuff is probably good to have when the entire data set is changed, but for my purpose I think I can get away with this.

March 22,

This topic is archived.

See also:

Back to support forum


Version 2

Looking for AW 2.6 ?
The old site is here.