Check the CGJQMultiselect.pas demo frame source and lookup for the method:
- Code: Select all
procedure TIWJQMultiSelectFrame.ProcessCommand(ACommand: Integer; AParams: TStrings);
Lookup for any of the options, and check one of the functions like 'LoadSelectOptions' there you will see that it uses a TIWCGJQMultiSelectItem object for each item and not a string as may it appear. Yes it has a stringlist, but for only showing the names, but each string item has associated an object to the string, the is need if you want to have a unique ID for each item that do not have to be the 'caption'.
- Code: Select all
procedure TIWJQMultiSelectFrame.LoadSelectOptions;
var
LItem: TIWCGJQMultiSelectItem;
I: Integer;
begin
IWCGJQMultiSelect.Items.Clear;
for I := 0 to 29 do
begin
LItem:= IWCGJQMultiSelect.Items.Add;
LItem.Caption:= 'Item ' + IntToStr(i+1);
LItem.Value:= 'item' + IntToStr(i+1);
end;
end;
Before populating the list remember to call always
- Code: Select all
IWCGJQMultiSelect.ResetJSonProps;
So maybe you will need to create a custom function (to reuse the code) to load your strings in a TstringList, parse each item in a For/loop and for each string item add the item object to the IWCGJQMultiselect control, as the example showed above. But instead of using the method
- Code: Select all
IWCGJQMultiSelect.Items.Add
Use the mtehod
- Code: Select all
IWCGJQMultiSelect.Items.AddOption(aCaption: string; AValue: string; aDisabled.Boolean; aSelected: boolean)
So you can specify if the item is selected at the moment of it creation so it will automatically added to the selected item list.
Also each TIWCGJQMultiSelectItem object has a read/write property named 'Selected'