duplicate items in combo-box: wrong screen-value returned

netfreaky

New Member
Hi all,

I'm population a combo-box with list-item-pairs from a database table. In my case, it's possible that there are duplicate items, but with a different primary key.

In this case, I've the following data:
id: 0 - value: (empty)
id: 1 - value: Roeselare
id: 2 - value: Rumbeke
id: 3 - value: Oekene
id: 4 - value: Beveren-Roeselare
id: 5 - value: Roeselare

So the list-item-pairs is ",0,Roeselare,1,Rumbeke,2,Oekene,3,Beveren-Roeselare,4,Roeselare,5".
When I assign this to the combo-box and get it back again, it gives me ",0,Roeselare,5,Rumbeke,1,Oekene,2,Beveren-Roeselare,3,Roeselare,4"

I also tried to fill the combo-box using the add-last function, this works wel until the duplicate item is putted in.
Again, the list-item-pairs go from ",0,Roeselare,1,Rumbeke,2,Oekene,3,Beveren-Roeselare,4," to ",0,Roeselare,5,Rumbeke,1,Oekene,2,Beveren-Roeselare,3,Roeselare,4".

The Progress knowledge center brings me to Bug# OE00057192, which is for Progress 9.x and tells to upgrade to version 10.0A. We already have version 10.1A.

Did anyone encounter this problem or knows something to solve it?
(i'll post the code if you want to, but it's too simple;) )

Thanks in advance!

Tom D'hoore
 

walkeryan

Member
I would check to see if your combo Box has the "Sort" property checked, Not sure if this will solve your problem but its worth a shot.
 

netfreaky

New Member
I would check to see if your combo Box has the "Sort" property checked, Not sure if this will solve your problem but its worth a shot.

Hi,

thanks for this, the "Sort" property wasn't checked. Checking it, gives the right screen-value but sorts the list by the label...

But there's a minor remark which doesn't make it the best solution:
The last duplicate item (the one with the highest id) is the first of the duplicates in the combo-box, it would be better if it's sorted by the combination label and id. It would be great if it could be only sorted by id.
 

walkeryan

Member
Hi,

thanks for this, the "Sort" property wasn't checked. Checking it, gives the right screen-value but sorts the list by the label...

But there's a minor remark which doesn't make it the best solution:
The last duplicate item (the one with the highest id) is the first of the duplicates in the combo-box, it would be better if it's sorted by the combination label and id. It would be great if it could be only sorted by id.

Then thats simple, remove the sort option, and when your loading your combo box
FOR EACH table NO-LOCK:
comboBox:ADD-LAST(stuff,stuffID).
END.

All you need to do is put a BY clause, Ex:

FOR EACH table NO-LOCK BY table.stuffID:
comboBox:ADD-LAST(stuff,stuffID).
END.

You can also use the DESC option to get a decending order.
 

netfreaky

New Member
Then thats simple, remove the sort option, and when your loading your combo box
FOR EACH table NO-LOCK:
comboBox:ADD-LAST(stuff,stuffID).
END.

All you need to do is put a BY clause, Ex:

FOR EACH table NO-LOCK BY table.stuffID:
comboBox:ADD-LAST(stuff,stuffID).
END.

You can also use the DESC option to get a decending order.

Hi,

I've already tried something likely (translated to english):

table post:
field land as char (country)
field post as char (postal code)
field lnr as int (line number, because it's possible that different parts of a city have the same postal code)
field lok as char (location)
index post: land asc, post asc, lnr asc.

---------------------
ASSIGN hanCmb:LIST-ITEM-PAIRS=",0".

FOR EACH post WHERE post.land=strLand AND post.post=strPost USE-INDEX post NO-LOCK:
hanCmb:ADD-LAST(upper(STRING(post.lok)),STRING(post.lnr)).

/* following is for testing purposes */
MESSAGE post.lnr " - " post.lok skip hanCmb:LIST-ITEM-PAIRS
VIEW-AS ALERT-BOX INFO BUTTONS OK.
ASSIGN strList = strList + "," + upper(STRING(post.lok)) + ","
+ STRING(post.lnr).
END.
---------------------
strList contains the correct list: ",0,Roeselare,1,Rumbeke,2,Oekene,3,Beveren-Roeselare,4,Roeselare,5".

but the last message (before the duplicate item) gives ",0,Roeselare,1,Rumbeke,2,Oekene,3,Beveren-Roeselare,4". After adding the duplicate entry, we get message "5 - Roeselare" (the correct one) and as list-item-pairs again ",0,Roeselare,5,Rumbeke,1,Oekene,2,Beveren-Roeselare,3,Roeselare,4"
 

dayv2005

Member
i really dont know if this will help you or not. But when you are saying you are getting duped fields in the combo box.

You could always use the delete attribute on the cb.

something like cb-comboBox:delete(n).

here's a sample of my code i used this to do once before. I hope this helps.

Code:
DO WITH FRAME {&FRAME-NAME}:

// this is the variable that controls what number field is being removed
[COLOR=Red]DEFINE VARIABLE myString AS CHARACTER  NO-UNDO INIT "00,05,07,12,14,15,32,13,16,17,21,25,31,39".[/COLOR]
    [COLOR=Red]DEFINE VARIABLE X AS INTEGER    NO-UNDO.[/COLOR]
   
    cb-Facility:DELIMITER = CHR(10).                                                               
    cb-Facility:LIST-ITEM-PAIRS = ?.                                                               
    cb-Facility:ADD-FIRST(" ALL","ALL").
                                                                                                     
             /* B-Facility                Physical file */
    FOR EACH FDG1REP WHERE FDG1REP.G1NOCD > "0" AND FDG1REP.G1NOCD <= "46" NO-LOCK:
        cb-Facility:ADD-LAST(FDG1REP.G1NOCD + " " + FDG1REP.G1BUNA, FDG1REP.G1NOCD).
    END.
        
[COLOR=Red]    REPEAT X = 1 TO NUM-ENTRIES(myString):
        cb-Facility:DELETE(cb-Facility:LOOKUP(ENTRY(X,myString))).
    END.[/COLOR]

    cb-Facility:ADD-LAST("14 ALLENTOWN", "14").
    cb-Facility:ADD-LAST("15 CORSICA", "15").
    cb-Facility:ADD-LAST("32 WALTON HILLS", "32").

    cb-Facility:SCREEN-VALUE = cb-Facility:ENTRY(1).
 END.                                       
END PROCEDURE.


You might have to tweak this to your specifications.
 

dayv2005

Member
i think my last post had nothing to do with what you were asking.

Try using a sort property on it or set an index using the id and use that in your query that is populating your cb object
 

netfreaky

New Member
I currently use a little work-around for this problem: I added the unique id to the label, so the label is "unique"...

But... I hope in a next version this will be solved.
 

walkeryan

Member
I currently use a little work-around for this problem: I added the unique id to the label, so the label is "unique"...

But... I hope in a next version this will be solved.

Good Deal, I can't believe there are so many errors in progress like these. MY favorite solution is (WE didn't wanna fix it so go spend thousands of dollars and upgrade to progress 10 if you dont want the error.... lol.
 

tamhas

ProgressTalk.com Sponsor
Why is upgrading to a current version a matter of spending thousands of dollars? Unless you haven't been paying your maintenance.
 

dayv2005

Member
Why is upgrading to a current version a matter of spending thousands of dollars? Unless you haven't been paying your maintenance.

He's just a hater, it isn't our money Muhahaha. But walker and I work for the same company actually his cube is right next to mine.
 
Top