ORDA: Wie Listbox mit neuer entityselection updaten?

Ich öffne ein Formular mit DIALOG und setze ein Formobjekt mit einer entityselection als property data:

<code 4D>
$formobj_o:=New object
Open form window(“Aktionen”;Plain form window;Horizontally centered;Vertically centered;)

</code 4D>

Das Formular enthält eine entsprechende Listbox vom Typ Collection or entity selection mit Form.data und Feldern per This.Feldname.

Nun habe ich einen Button, der eine ganz andere Auswahl bzw. entityselection herstellen soll, d.H. dieselbe dataclass aber eine andere query. Leider updatet die Listbox sich nicht. Der Buttoncode:

<code 4D>
REDRAW(OBJECT Get pointer(Object named;“List Box”)->)
REDRAW WINDOW(Current form window)
LISTBOX SORT COLUMNS(*;“List Box”;8;>;2;<)

</code 4D>

Ich habe mal beide Redraw-Funktionen verwendet. Der Witz ist: Manchmal klappt es. Meistens aber tut sich nichts. Object Get Pointer funktioniert.

Woran könnte es liegen?

Did you try to update the current form with a CALL FORM command?

Why would I? The Buttons are in the same form as the listbox. There was even an example from the master class with JPR in which he changes the selection with some query 1, query 2 etc. - Buttons, that don’t do anything but set the listbox-Form.data object with a new ds.dataclass.query.
I don’t know what to put into the method called by CALL FORM. I tried a beep and it is executed, but no change.

Funny thing: After setting the Form.data object with a new ds.dataclass.query, I can see the change of the length in the debugger. The entityselection is changed, but my listbox is not.

There are 2 ways for that:
and the one you are looking for is to reaffect to itself the Form.data

Add at the end of your code:


should work.

Damn, it’s a bug. I found a solution. What I did not say was that I sort the listbox right after the change of the selection. This kills it. Damn, I hoped I could use the new stuff without too much problems.
The listbox has 9 columns, I do a multi-column sort:

<code 4D>
LISTBOX SORT COLUMNS(*;“List Box”;8;>;2;<)

</code 4D>

If I comment it out, the new selection is loaded.

: Patrick EMANUEL

There are 2 ways for that:
and the one you are looking for is to reaffect to itself the Form.data

Add at the end of your code:


should work.

Not needed. Works without that (and should!), but the lisbox sorting seems to revert back to the old selection.

on your query, why don’t you apply an ‘orderBy’ on column corresponding to your listbox?

I did that now. This solves my problem, but still I consider it a bug.
Using an unordered selection and then sorting the listbox sets the listbox column headers correctly to reflect the sort, so it seemed cleaner to me.

Anyways, thanks for your help!

Official Answer: LISTBOX SORT COLUMNS is meant for array-based listboxes only. Therefore not a bug.

Should this information needs to be added in the official documentation by 4D

The question from Mr Mueller via TAOW was not the same as here in this thread.
It was about how to use LISTBOX SORT COLUMNS for orda based listbox.

The documentation says:
In colNum, pass the column number of the column whose values you want to use as the sort criteria. You can use any type of array data, except pictures and pointers.

You can define multi-level sorts: to do so, pass as many pairs (colNum;order) as necessary. The sorting level is defined by the position of the parameter in the call.

The command handles the sort of array based list boxes, by automatically keeping all arrays in sync.

For Selection based list boxes use ORDER BY.

For ORDA based list boxes use .orderBy.

Mr Mueller asked via TAOW how to have the arrow symbols in the list box header showing the order. Our code example was:
<code 4D>
$varptr:=OBJECT Get pointer(Object current)
$name:=“beendet” // based on his example
If ($varptr->=1)
Form.listbox:=Form.listbox.orderBy($name+" desc")
Form.listbox:=Form.listbox.orderBy($name+" asc")
End if
End if
</code 4D>

Our answer was given for his request in the case (how to sort an order based list box).

Damned, a mix of question and answers :wink:

anyway. Thanks for sharing the example.


I did not fill a TAOW case to ask how to use this command with ORDA listboxes. I filled a case with this text (just the first sentence):

If you have a listbox of type entity selection and a button, that should change the selection and then do a listbox sort columns, the changed entity selection is discarded, like listbox sort columns restores the old selection.

Anyways, I am OK with the solution (don’t use this command in this context).

Still it might be nicer if the command would do nothing in this case instead of doing crazy things. As I said, the command does work with ORDA, if you don’t change the selection at the same time.