:: Forum >> Version 2 >>

XML data refresh bug when sorted descending in 2.0.1

I'm having an issue with refreshing XML data in the grid while there is a descending sort in place.

In the following example, if you sort by column 0 ascending and click the "changedata" button, everything works correctly.

But, if you start over and sort by column 0 descending, the grid only shows the data for 2 of the rows. The new grid count is correct, but the data is blank for most rows.

This only seems to happen if the number of rows changes.

Anybody know of a work around?


<html>
<
head>
    <
title>ActiveWidgets Grid :: Examples</title>
    <
stylebodyhtml {margin:0pxpadding0pxoverflowhidden;} </style>
    <!-- 
ActiveWidgets stylesheet and scripts -->
    <
link href="../../runtime/styles/xp/aw.css" rel="stylesheet" type="text/css" ></link>
    <
script src="../../runtime/lib/aw.js"></script>
    <!-- 
grid format -->
    <
style>
        .
aw-grid-control {height200width100%; margin0pxbordernonefontmenu;}
        .
aw-row-selector {text-aligncenter}
        .
aw-column-{width:  80px;}
        .
aw-column-{width200px;}
        .
aw-column-{text-alignright;}
        .
aw-column-{text-alignright;}
        .
aw-column-{text-alignright;}
    </
style>
</
head>
<
body>
    <
input type="button" value="changedata" onclick="changeData()" />

    <
script>
    
    var 
count 0;
    function 
getXml(rowCountextra){
        if(!
extra){
            
extra "";
        }
        var 
xml "<data>";
        for(var 
row=0;row<rowCount;row++){
            
xml += "<row>";
            for(var 
col=0;col<5;col++){
                
xml += "<col"+col+">" extra +  + row ","+  col "</col"+col+">"  ;
            }
            
xml += "</row>";
        }
        
xml += "</data>";
        return 
xml;
    }
    
    
    
    function 
getDocumentFromString(xmlString){
        
//    IE
        
if (window.ActiveXObject) {
            var 
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
            
xmlDoc.async="false";
            
xmlDoc.loadXML(xmlString);
            return 
xmlDoc;
        }
        
//    Mozilla
        
else {
            return new 
DOMParser().parseFromString(xmlString"text/xml");
        }
    }
    
    
    function 
changeData(){     
        
table.setXMLgetDocumentFromString(getXml(6"change " count " " )) );
        
count += 1;
        
obj.setRowCount(table.getCount());
        
obj.refresh();
    }
    
    var 
obj = new AW.UI.Grid;
    
obj.getHeaderText =  function (i) {return  "Column " };
    
    var 
table = new AW.XML.Table;
    
table.setColumns( ["col0","col1","col2","col3","col4"]);
    
table.setXMLgetDocumentFromString(getXml(10)) );
    
obj.setCellModel(table);
    
    
obj.setRowCount(table.getCount());
    
obj.setColumnCount(5);
    
obj.setSelectionMode("single-row");
    
document.write(obj);

    </
script>
  
</
body>
</
html>  
Mike Graessle
Monday, August 7, 2006
Mike, I'm not really sure ( and wolud preffer that Alex confirm/clarify it )
, but I think it is related to:
/javascript.forum.11480.5/refresh-content-in-grid.html
After a few testing, clearRowModel() seems to do the trick.

function changeData(rows){
obj.clearRowModel();
table.setXMLgetDocumentFromString(getXml(rows"change " count " " )) ); 
count += 1
obj.setRowCount(table.getCount()); 
obj.refresh(); 
 } 
Carlos
Monday, August 7, 2006
Sorry Mike, that breaks the sort order ( So less sure than before), but if this is the right workaround ??? then, re-sort is needed:
function changeData(){  
var 
obj.getSortColumn(); 
var 
idir obj.getSortDirection(i);
obj.clearRowModel();
table.setXMLgetDocumentFromString(getXml(6"change " count " " )) ); 
count += 1
obj.setRowCount(table.getCount()); 
obj.sort(iidir);
//obj.refresh(); 
 
Carlos
Monday, August 7, 2006
Thanks Carlos. That seems to fix the issue, while preserving the sort order.
Mike Graessle
Tuesday, August 8, 2006



This topic is archived.

Back to support forum

Forum search