:: Forum >>

Refreshing grid after xpath filtering not working anymore ?

Hi

I am encontering a strange regression bug moving to 2.1 to 2.5


I have an Extended grid i am using for a customer apllication.

I have built a custom header with drop down listing each distinct value in each column.
(the distinct sorting is done in the XML and the grid use xpath to separate the content of the rows, from the data to put in the filtering combo)

Using the drop down actually filter the grid combining xpath.
Much like Excel.

the whole grid aplication is prety much complex, but basicaly the filter logic is just:
- applaying an xpath to the the table object,
- then loading the whole xml (saved as a js var to be abled to keep the whole data after filtering so you can keep changing the filter)
- SetRow count to the grid and various text info in the footer.
- refreshing.

This used to work like a charm in 2.1, and quite fast.
Now in 2.5 the filtering do work but not the refresh, and i have to move the grid scrollbar so i actuallly see the change and the footer never refresh.
the grid.refresh() seams to take no time and have no effect.

I dont's see exctly what is going wrong and do need to upgrade for better Firefox 3 support.

Do you have any idear on what the problem could be ?

here is a very simplified (but still non working) part of the code involved :

var myGrid = new AW.Grid.Extended;
myGrid.setId("myGrid");
myGrid.setHeaderCount(2);
var myHeaders = ["Numero","Demande","Site","Domaine","Sous domaine/Famille","Elements","Statut","Etat","Date d'émission","Date de début","Date de fin","Durée"]
var myHeadersflt = ["", "", "", "", "", "", "", "", "", "", "", "", ""];
myGrid.setHeaderText(myHeaders, 0);
myGrid.setHeaderText(myHeadersflt, 1);
myGrid.setColumnCount(12);


var currentFilter = new Array();

function filter_grid() //revoir modele -> prototype de filtres
{
    var strxpath = "";
    if (currentFilter["demtypeCombo"]) {
        strxpath += "dem/@eid=\"" + currentFilter["demtypeCombo"] + "\"";
    }
    table.setRows("//matrice/ligne["+ ((strxpath)?strxpath:"*") +"]");
    table.setXML(wholeXML);
    myGrid.setFooterText(["Total:", table.getCount() + " demandes",]);
    myGrid.setRowCount(table.getCount());
    myGrid.refresh();

    

}

var demtypeCombo = new AW.UI.Combo;
demtypeCombo.setControlText("filtre");
demtypeCombo.setItemText(["filtre"]);
demtypeCombo.setItemValue([""]);
demtypeCombo.setItemCount(1);
demtypeCombo.onItemClicked = function(event, i){
    currentFilter["demtypeCombo"]=this.getItemValue(i);
    filter_grid();
}
myGrid.setHeaderTemplate(demtypeCombo, 1, 1);
demtypeCombo.setAttribute("aw", "control"); // restore 'control' behavior
demtypeCombo.getPopupTemplate().setStyle("width", "100%");
var demtypeNomArr = new Array();demtypeNomArr[0]="Tous";
var demtypeIdArr = new Array();demtypeIdArr[0]=0;


var table = new AW.XML.Table;
myGrid.setCellModel(table);
myGrid.setVirtualMode(true); //Virtual Mode

table.setAsync(true);
table.setURL("/analyses_matrice_request.php?idx_commu=58&matid=&submit_tbl=1");
table.setRequestMethod("POST");

table.response = function(text) {
    wholeXML = text;
    table.setXML(text);
    table.setRows("//matrice/demandes[*]");
    table.setXML(text);
    for (a=1,l=0; l<table.getCount();a++,l++ ) {
        demtypeNomArr[a]=table.getData(1,l);
        demtypeIdArr[a]=table.getData(0,l);
    }
    demtypeCombo.setItemText(demtypeNomArr);
    demtypeCombo.setItemValue(demtypeIdArr);
    demtypeCombo.setItemCount(table.getCount()+1);
    table.setRows("//matrice/ligne[*]");
    table.setXML(text);
    myGrid.setFooterText(["Total:",table.getCount() + " demandes",]);
    myGrid.setRowCount(table.getCount());
    myGrid.refresh();
}
table.request();
myGrid.setFooterVisible(true);
document.write(myGrid);



Thanks for your help
Thomas Duquette
Tuesday, October 21, 2008
To be more specific, i forgot to say i am trying to port to the new commercial 2.5.3 version, and that it was running ok in a commercial 2.0.1.
Thomas Duquette
Tuesday, October 21, 2008
I have included 2 links to show the diference between the 2 version


http://media.a-g.fr/aw/2.0.1/test.html

http://media.a-g.fr/aw/2.5.3/test.html


as you can see it is the exact same code and XML one is working and the other is not.

I think this has somthing to do with timming.
If i do a 5 second setimout on refresh it "somtime" works.

But waiting 5 sec for filtering 65 row is not normal and as shown with 2.0.1 it shoudl take a few millisecond. (in production the grid can have over 25 000 rows, and then it was normal to wait ...)

i tried several method to be shure to wait for the table data to be ready but never found one that was convinient.
Thomas Duquette
Thursday, October 23, 2008
var myHeaders = ["Numero", ........."Date d'émission","Date de début","Date de fin","Durée"];

Your XML file could contain too some accent/tilde chars like áàéèíìóòúù.
Those (and others) are special characters not supported in XML neither in AW.
The case ("Date d'é") = causes a JS array string error in " d' ".
Please search for "encoding" on this forum, and also check:
http://www.activewidgets.com/javascript.forum.8124.3/encodings.html
http://www.activewidgets.com/javascript.forum.19844.2/thai-language-incorrect-present-when.html
HTH
Thursday, October 23, 2008
thanks for the sugestion.

But aparently the problem was not the use of non ANSI char.

For a better exemple i have removed in the 2.5.3 exemple link all the non basic ANSI char, and suppressed any single quote.
I olso have saved the page in UTF-8 .

Adding : <?xml version="1.0" encoding="UTF-8" ?> to the XML header doesn't help

now 2.5.3 is still non working with basic char, while the 2.0.1 is (even in wrong charset, with single quote and French char ...)
Thomas Duquette
Tuesday, October 28, 2008
I could be wrong, but I would change the lines order into the filter function. ( it might need few more adjusts)
check also this post.
http://www.activewidgets.com/javascript.forum.19871.11/filter-built-into-header-in.html
http://www.activewidgets.com/javascript.forum.22570.11/need-help-with-filter-based.html
function filter_grid()//revoir modele -> prototype des filtres
{
var strxpath = "";
myGrid.clearRowModel();
myGrid.clearSortModel();
myGrid.clearScrollModel();
table.setXML(wholeXML);
myGrid.setRowCount(table.getCount());
if (currentFilter["demtypeCombo"]){
strxpath += "dem/@eid=\"" + currentFilter["demtypeCombo"] + "\"";
}
table.setRows("//matrice/ligne["+ ((strxpath)?strxpath:"*") +"]");
myGrid.setFooterText(["Total:", table.getCount() + " demandes",]);
myGrid.refresh();
}

Carlos
Tuesday, October 28, 2008
Uffff, sorry for the last post,
After a deeper testing I notice that (on IE6) the filter is applyed, just does not refreshed (unless scroll ), so, replace :
myGrid.refresh();
with this:
myGrid.getRowsTemplate().refresh();

and all goes OK , (would suggest also try to remove some/all lines below )

myGrid.clearRowModel();
myGrid.clearSortModel();
myGrid.clearScrollModel();
table.setXML(wholeXML);
myGrid.setRowCount(table.getCount());

HTH
Carlos
Tuesday, October 28, 2008
YES !!!


Thanks so much :)

that was it, this works.

and folowing your idea i just have to do:
myGrid.getFooterTemplate(1,0).refresh();
to refresh the footer and get a proper row (filtered) count display.

now i just don't understand why i have to access the grid by it's sub-elemnt to re-render it once filtered, and can't just refresh the whole grid in 2.5.3.
but as long i can make what i whant works, i can upgrade..
beside, refreshing just the needed sub-part is a more optimised code ...

So thanks again Carlos for your time and for going into actual testing, this really helped me out

Thomas Duquette
Wednesday, October 29, 2008

This topic is archived.


Back to support forum

Forum search