Focal Point
[SOLVED] Problems with sorting in listboxes, downboxes

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/2467073226

July 19, 2012, 04:20 AM
Piter
[SOLVED] Problems with sorting in listboxes, downboxes
Hello,

I use non english collations with local characters like Ą, Ä, Š etc. By default Webfocus will sort letters like ABC...S....abc...s...Ä...Š. This is kind of computerized way, which not following rules of languages, wher usualy letters must be sorted like A,Ą,Ä,B...SŠ.... Letters with 'ogonek' or 'caron' have the same sorting weight like standard letters.

To solve the issue, I modified cpnnnnn.nls file. (Way how to do it described in http://www.informationbuilders...WFNSummer06AppCP.pdf)
I went to the server console NLS section, checked "recreate focus files' and restarted server.

As result, sorting in reports start to work like it must be. (Letters with caron goes after standard letter).

But sorting in listboxes and downboxes stays not changed (where letter with caron goes after Z). May be anybody knows how to solve this problem?

Thank you in advance.

WF7703
Tomcat standalone

This message has been edited. Last edited by: Kerry,


Wf7704/WF8,Win64/32
July 19, 2012, 06:01 AM
Wep5622
Not possible I think. Sorting data in list- and dropdown-boxes is done using Javascript, and that language has no knowledge of NLS or any means to apply it to your strings.


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
July 19, 2012, 06:31 AM
Piter
Thank you Wep.

What do you think - is it set in Tomcat, or in Java on server machine or in ibi war files? Is there some webfocus xxx.js file source of problem? Or where it can be?

I was thinking that may be it is not a fault of Webfocus, but when I look on html code of particular listbox, there is a lot of parameters used by some of WF component. As result I feel that WF (some component) manage sorting in lists.

p.s. I spend some time to look more and more and more I am thinking that this is bug. For me it looks that WF manages sorting in listboxes and do it through (probably) ibirls3.js file. For sorting simple array.sort() is used which sorts in 'computerized' way, not according the language rules. How to solve this....?

This message has been edited. Last edited by: Piter,


Wf7704/WF8,Win64/32
July 19, 2012, 09:38 AM
susannah
Piter, how do you create your dropdown lists? do you just point to a master file ? or do point to a fex to generate the list for you?
If you point to a fex, then you can order the elements anyway you want to.... does that make sense to you?




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
July 19, 2012, 09:57 AM
Wep5622
quote:
Originally posted by Piter:
What do you think - is it set in Tomcat, or in Java on server machine or in ibi war files? Is there some webfocus xxx.js file source of problem? Or where it can be?

I was thinking that may be it is not a fault of Webfocus, but when I look on html code of particular listbox, there is a lot of parameters used by some of WF component. As result I feel that WF (some component) manage sorting in lists.

p.s. I spend some time to look more and more and more I am thinking that this is bug. For me it looks that WF manages sorting in listboxes and do it through (probably) ibirls3.js file. For sorting simple array.sort() is used which sorts in 'computerized' way, not according the language rules. How to solve this....?


I think it is indeed done in the ibirls3.js file, which means that the actual sorting happens client-side - in the user's web browser. It definitely doesn't happen in tomcat or the JVM or in an IBI war file, which means you have no control over this type of sorting.

But, as susannah correctly points out, if you use en 'external procedure' you can do the sorting anyway you want. It's just the 'embedded procedures' that are limited in this way. Using external procedures though, you will have to create a fex for every list in your launch pages that need alphabetical sorting. There's still the "old" method using !IBI.FIL.SOMEALPHAFILE; too, but I don't think that supports chaining of form-elements (never used it much).

Neither of the options is ideal.


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
July 24, 2012, 11:56 AM
Piter
Susanna, Wep

thank you for your help.

1. Wep - you are right - depending on version of browser, I can get correct sorting in listboxes. But it is a bit not enough for me. I like to have it correct in all cases.

therefore I start to look on Susanna's proposal.

2. I went via solution proposed by Susanna. When I create listbox, I point in DeveloperStudio - Dynamic, then I there are 2 choices - external or embedded procedure. When I point embedded, then it ask for .mas file. and as result creates something like

TABLE FILE MASTER
SUM FST.ID
BY NAME
ON TABLE HOLD FORMAT XML
END

If I run such procedure - in separate window - result (sorting) is correct. But result in list is wrong.

If I pointing use 'external procedure' (i.e. with the same content like above) then developer studio copies text of procedure into window and result is the same.

In both cases sorting incorrect.

What is strange, in generated HTML file there are 2 options:

sorttype="1" dosorting="1".

I was thinking, that If I will do sort in procedure, then I can switch sorting off (set to 0) and sorting on screen will be fine. But it looks that WF do not use sorting made by procedure.

What do you think about that - where I am wrong?

Thank you for your help.


Wf7704/WF8,Win64/32
July 24, 2012, 12:31 PM
j.gross
If dosorting==1, sorting takes place in the browser, using locale-dependent string comparison:
Ib_dataInfoObject.prototype.doSorting = function (array)
{
    if(this.isSortingSet())
    {
        var object = this;
        sortValues  = function (first, second)
        {
            var byValue = object.isSortingByValue();
            var bDessending = object.isSortingDessending();
            var AllOptionElement1 = first.value;
            var AllOptionElement2 = second.value;
            if(AllOptionElement1 == allValue)
              return -1;
            if(AllOptionElement2 == allValue)
              return 1;
            var valueFirst = byValue ? first.value : first.dispValue;
            var valueSecond = byValue ? second.value : second.dispValue;

            if(valueFirst && valueSecond)
            {
                return bDessending ? valueSecond.localeCompare(valueFirst) : valueFirst.localeCompare(valueSecond);
            }
            return 0;
        };
        array.sort(sortValues);
    }
}  


So the results would indeed depend on "locale" setting in the client.



If you dosorting off, and turn off caching, I would expect the sort-order returned by your internal or external fex to be respected. (Even with caching on, I would still expect the matching subset to retain its order.)


If that's not the case, time to open a case with Customer Support.
July 24, 2012, 01:05 PM
susannah
here's a q&d example of an external procedure that sorts stuff for a dropdown
DEFINE FILE IBISAMP/CAR
LEVEL/A10=DECODE COUNTRY ('ENGLAND' 'NONE' 
                           'JAPAN'  'CAR'
                           'ITALY'  'COUNTRY' ELSE 'MODEL');
LEVELORDER/I1=DECODE LEVEL ('NONE' 1 'CAR' 2 'COUNTRY' 3 ELSE 4);
END
TABLE FILE IBISAMP/CAR
SUM LEVEL BY LEVELORDER NOPRINT
ON TABLE PCHOLD
END


so write a fex that accomplishes the sort that you want, however you need to do that. store the fex in the same domain/folder as your launch page and report
July 30, 2012, 04:34 AM
Piter
Thank you, Susanna. Your solution work! I created fex, made reference to external procedure in DevStudio , refreshed procedure (in DevStudio), placed fex at WF server, new html on web machine and all works.

p.s. When I tried to implement your solution first time (and failed) I have not pressed "refresh external procedure" in Developer studio. As result, probably Developer studio was storing old references to wrong procedure.


Wf7704/WF8,Win64/32
July 30, 2012, 04:48 AM
Piter
quote:
Originally posted by j.gross:

If you dosorting off, and turn off caching, I would expect the sort-order returned by your internal or external fex to be respected. (Even with caching on, I would still expect the matching subset to retain its order.)


I have checked one more time. j.gross - you are right. Probably I was leaving "Sort" mark checked and as result, even my procedure was fine, browser was doing one more 'incorrect' sorting.

Thank you All for your help!


Wf7704/WF8,Win64/32