Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 4 Jahren, 11 Monaten
Letzter Beitrag:
vor 4 Jahren, 11 Monaten
Beteiligte Autoren:
Arie, Piet van Zanten, Fabrice Harari

wb17 - listbox value in browsercode

Startbeitrag von Arie am 02.08.2013 18:54

Hi, beginner question.
in browsercode (and in WD) we have the gLink() option. In browser code not.
Say I have a list of products shown in a listbox. How do I get the productID when the user selects a row?


Hi Arie,

Can you explain why you would use browsercode instead of server code?


von Piet van Zanten - am 02.08.2013 19:20
Hi Piet,
I have an edit control where user can type part of a productcode. Then I want to show a list of found products. The editbox does not have server events??
ps: I'm coming from WD so maybe this is a wrong way of doing things in WB.

von Arie - am 02.08.2013 19:27
I also tried Ajax using this:

So the listbox is shown in a cell, like a popup.
Then the first time I see the cell, it is empty.
2nd time I see the product I requested the first time.
3th time I see the product I requested the 2nd time.
And so on.
Why is that?

von Arie - am 02.08.2013 19:31
Hi Arie,

In what event is the Ajaxexecute in the editbox or in a button?
If it's a button did you define the action in the general tab to "none"?


von Piet van Zanten - am 02.08.2013 20:12
Hello Arie

When I have this need, I use one of the 2 following ways (depending on the problem)

1. In the browser code, I call a server function using ajaxexecute and passing the line number (its the value returned for the list control in browser code) to it... I make sure that on the browser side the listbox is populated the same way (not always the cas in awp) and get the ID with the glink in the server code, based on the line number passed as parameter...

2. The second way is a drawback to the time when the glink option did NOT exist... It consist of HIDING the id value inside the control itself... To do that, the value added in the control must be DISPLAYED_Value+Repetition of unbreakable spaces (charact of 160, if my memory is correct)+ID value
Of course, the number of spaces added MUST be big enough so that the ID is not visible... A simple extractstring of the line allows to get the hidden ID

Best regards

von Fabrice Harari - am 03.08.2013 01:27

it is in "Exit with modification (onchange)" of the editcontrol - when user tab out of it

von Arie - am 03.08.2013 11:15
Hi Arie,

What would explain this behaviour is that somewhere along the line the page is submitted to the server.
Then the state of the page will always be a step behind.
There must be something in the FillProducts procedure that triggers a page submission.
Possibly the "Whenever modified" event of the listbox does that, try setting it to Ajax mode.
Perhaps you can find other code that triggers a page submission.


von Piet van Zanten - am 03.08.2013 11:46
you were right. I missed some test-code. Got this working now.

von Arie - am 03.08.2013 12:43
Thanks Fabrice,
it works now.
1. Get a list of products using AjaxExecute() as id+TAB+descripion+CR+id+TAB+description+CR+ etc
2. Store this info in a global page variable
3. Use this info to populate the listbox
4. Show the listbox (popup)
5. whenever the user selects a row, use the global sProducts var to get the productID
6. store the productID in a looperattribute (I'm using a looper to add several orderlines on an order)

5+6 are done in browsercode to get maximum performance.
Maybe I will load ALL products once at page opening, to get even better performance later on (step 1).
Then I have no server-calls at all during editing/adding orderlines.

von Arie - am 03.08.2013 13:12
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.