TWebComboBox isues

I loaded name=value pairs into the combobox.Items list, and when the dropdown appears, the name= parts are missing. I don't mind that if there's a way to disable this feature, but I can't find one. In this case, I want to show them both.

Actually, there's a property ExtendedUI that I thought might do it, but it generates an 'identifier not found' compiler error.

Interesting. I'd have thought it would show the name and hide the value. Have you tried TWebLookupComboBox? You could set the Value as the value you want to retrieve and the DisplayText as Name=Value.

The combobox maps on the HTML SELECT element:

It gives via name/value access to the OPTION element value & innerHTML.

That's all well and good, but ... the combobox.Text VALUE is NOT what's DISPLAYED as the TEXT parameter!

combobox.Items.Add( 'abc=def' );
combobox.Items.Add( 'uvw=xyz' );
...
// user select first item and the combobox SHOWS: "def"

However ...

ShowMessage( IfThen( (combobox.Items[0] = combobox.Text), 'true', 'false' ) ); // shows "true"
ShowMessage( IfThen( (combobox.Text = 'def'), 'true', 'false' ) ); // shows "false"

because

ShowMessage( combobox.Text ); // shows 'abc=def'

BTW, this makes eliminating dups rather complicated.

Yes, a bit strange that. It creates

<select id="TForm1_ComboBox3">
<option value="Name1">Value1</option>
<option value="Name2">Value2</option>
</select>

So you would expect combobox.text to return Value1 or Value2. Maybe what it needs is a GetValue method to return the value and text return just the name. If the '=' is not used then they'd return the same.

Not sure if it's allocating the Name,Value the right way round, but that might just be me.

It's typed as TStrings, so it should BEHAVE like TStrings, not THTMLSELECT.

Tested this in VCL app:

procedure TForm3.Button1Click(Sender: TObject);
var
  s1,s2: string;
begin
  s1 := combobox1.Items[0];
  s2 := combobox1.Text;

  outputdebugstring(pchar(s1));
  outputdebugstring(pchar(s2));

end;


procedure TForm3.FormCreate(Sender: TObject);
begin
  combobox1.Items.Add( 'abc=def' );
  combobox1.Items.Add( 'uvw=xyz' );
end;

and tested this in TMS WEB Core

procedure TForm1.WebButton1Click(Sender: TObject);
begin
  console.log(webcombobox1.Items[0]);
  console.log(webcombobox1.Text);
end;

procedure TForm1.WebFormCreate(Sender: TObject);
begin
  webcombobox1.Items.Add( 'abc=def' );
  webcombobox1.Items.Add( 'uvw=xyz' );
end;

and the behavior is the same:

image

I concur. Now show me a screen shot of how these items appear in the Combobox's dropdown. In my case, they show up as:

def
xyz

The Items property is typed as TStrings, and this is NOT how TStrings works on any other component I've ever seen. If anything, it should show

abc
uvw

If you put them in as:

abc=xyz
uvw=def

then the combobox shows them as

xyz
def

and if you copy it into a TStringlist, sort them, and copy them back into the Items you still see:

xyz
def

because the name= parts are being hidden. The combobox should show the entire name=value pairs in the dropdown, eg.

abc=xyz
uvw=def

If you Add these to the combobox:

1=John
2=Fred
3=Jane
4=Fred
5=Cindy

the combobox will show:

John
Fred
Jane
Fred
Cindy

and if you put it into a TStringlist with .sorted=True and .Dups=dupIgnore, then copy it back into combobox.Items, you'll end up with the exact same thing showing up in the combobox dropdown.

TStringlist IS A TStrings. So is TWebCombobox.Items.

I don't care if TWebCombox.Items is typed as, say, THTMLSelect, which is how it behaves. But it's typed as TStrings, and so it should behave like TStrings in so far as what the user actually sees in the the combo's dropdown list. That's all I'm saying.

Well, we are in a web environment so we accommodate for the capabilities the browser supports.
A classic Windows COMBOBOX control doesn't have something like a value attribute and content but the browser does with the HTML SELECT & OPTION elements and we want to offer access to this functionality so users can take advantage of it.
This is how it is and changing it will break how other users might have been using this for a while now, so we are not going to introduce breaking changes.