Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TIWComboBox + OnAsyncChange + ItemsHaveValues
#6
(12-18-2021, 04:58 PM)MJS@mjs.us Wrote: Let's circle back to points in my first post:

1.  The ItemIndex seems to be affected by the Values[] column.

2.  Desired behavior is for ItemIndex to be updated to the true selection offset regardless of the Items content.

We should focus on these points as opposed to how ItemsHaveValues was implemented.


>>[KUDZU]: IWComboBox mirrors TComboBox in behavior as it shares the same RTL routines.

If I add these to a TComboBox Items property:

A=1, B=1, C=1, D=2
or
'','','',''

the correct ItemIndex is always returned on selection, ItemIndex is not dependent on Items content.  ItemIndex always means selected offset.



>>[KUDZU]: TStrings has built in methods for the keys and values, and its how they work. They dont deal with duplicates.

If IWComboBox/ItemsHaveValues=true only uses TStrings built-in methods and cannot return a ItemIndex as true selected offset then I guess it needs
more logic beyond TStrings.

>> Let's circle back to points in my first post:

Agreed.

>> 1.  The ItemIndex seems to be affected by the Values[] column.

That's correct and I would expect so. Remember that ItemIndex is a read//write property but in order to fully understand it, you need to separate each part, the getter, and the setter. 

When you think about the getter, ItemIndex shows the offset of the *selected* item but - and here is the catch - once the selected *key* (the value) is received from a browser request, the selected offset (or ItemIndex) is determined searching for a match in the Values[] column.

>> the correct ItemIndex is always returned on selection, ItemIndex is not dependent on Items content

I don't agree here. As I explained above, the user selection (that happens on the browser) does not select an element position (or index) but instead, it selects an element *key* (or the value). The value is used to "calculate" the ItemIndex on the server-side.

I'll check your example once more and see If I have any other suggestion to make it work as you want, but the ComboBox behaves that way by design.
Reply


Messages In This Thread
RE: TIWComboBox + OnAsyncChange + ItemsHaveValues - by Alexandre Machado - 12-20-2021, 09:46 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)