CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

CGJQMultiSelect

by esthermann » 16 Jul 2013 23:44

I am trying to use this CGJQMultiSelect to save user input and then reload the selection from my datasource. I see the getMultiSelectData function, however, my Item list is static, I just want to load the SelectedItems each time.

There is a property for this. Since it's a string list, shouldn't I be able to do this?
lstObjectives->SelectedItems->DelimitedText = Data->tblBackground->FindField("ObjectiveList")->AsString;
lstObjectives->AjaxReRender();

I am comparing it to the demo, I just don't see a function for loading the selected data into this control. I can save the selection data without any issues at all. I am sure I am missing something very simple
esthermann
 
Posts: 171
Joined: 22 Jun 2012 11:17

by fduenas » 17 Jul 2013 00:02

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' :)
Last edited by fduenas on 17 Jul 2013 00:23, edited 2 times in total.
fduenas
 
Posts: 124
Joined: 29 May 2012 12:54

by esthermann » 17 Jul 2013 00:17

fduenas wrote: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 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.


I understand, I interpreted the code below to fill the list of items to BE selected not the list of items that had BEEN selected. I am not seeing where the items are being marked as selected in the code below. I only see them being added to the list. Certainly I can interate through my saved selection and manually mark the items selected, it just appeared that the SelectedItems list was a StringList containing the selected values. I thought perhaps I could just populate that property?

fduenas wrote:
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;
esthermann
 
Posts: 171
Joined: 22 Jun 2012 11:17

by fduenas » 17 Jul 2013 00:19

Hi I just reedited my last post maybe when you were posting yours, sorry is the first time I review that component, please see the last paragraph :)
Last edited by fduenas on 17 Jul 2013 00:28, edited 2 times in total.
fduenas
 
Posts: 124
Joined: 29 May 2012 12:54

by esthermann » 17 Jul 2013 00:22

Super funny, I think we were thinking on exactly the same lines. :D
esthermann
 
Posts: 171
Joined: 22 Jun 2012 11:17

by fduenas » 17 Jul 2013 00:26

esthermann wrote:Super funny, I think we were thinking on exactly the same lines. :D

Indeed :D, Also if you check the properties you will see each TIWCGJQMultiSelectItem object has a read/write property named 'Selected' :)

CGDevSupport: Maybe changing one of the demos or adding a new one showing the 'Selected' feature could be helpful
fduenas
 
Posts: 124
Joined: 29 May 2012 12:54

by Alexander Bulei » 17 Jul 2013 09:38

Hello,

At this moment, the selection of item is not supported in ajax, so you must call AjaxReRender at end.

Code: Select all
IWCGJQMultiSelect1.AjaxReRender


Simple demo attached.

P.S:

Code: Select all
IWCGJQMultiSelect.ResetJSonProps;


Will reset all properties and events to default.

Best Regards.
You do not have the required permissions to view the files attached to this post.
Group: Developers | Support Team

  • info [at] cgdevtools.com - General information
  • sales [at] cgdevtools.com - Sales department
  • support [at] cgdevtools.com - Product and Technical Support
User avatar
Alexander Bulei
Site Admin
 
Posts: 3635
Joined: 15 May 2012 08:52
Location: Mealhada, Portugal


Return to JQMultiSelect

Who is online

Users browsing this forum: No registered users and 2 guests

Contact Us.