CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

Changed behaviour

by etwoss » 01 Mar 2016 10:46

Hi

I went back to a project from about 6 month ago, where i added a JQAutoComplete to a Form.
With your help i get it working.

Added code:

Code: Select all
 BrowerParam:= IWCGJQAutoComplete.JQAutoCompleteOptions.OnSelect.BrowserParams.Add;
 BrowerParam.ServerName:= 'myuid';
 BrowerParam.BrowserScript:= 'ui.item.uid';


The Json is filled

Code: Select all
  for i := 0 to BaseDataCache.UserList.Count -1 do
  begin
    if pos(Uppercase(ATerm),Uppercase(BaseDataCache.UserList[i])) > 0  then
    begin
      ItemJSon:= SO();

      if  (Copy(BaseDataCache.UserList[i], Pos('[IM3]', BaseDataCache.UserList[i])  + 5, 1)= '-') then
        LLabel := Copy(BaseDataCache.UserList[i], 1, Pos('[IM1]', BaseDataCache.UserList[i]) - 1)
      else
        LLabel := Copy(BaseDataCache.UserList[i], 1, Pos('[IM1]',BaseDataCache.UserList[i]) - 1) + ' (' +
                  Copy(BaseDataCache.UserList[i], Pos('[IM3]', BaseDataCache.UserList[i])  + 5, Length(BaseDataCache.UserList[i])) + ')';

      LValue := Copy(BaseDataCache.UserList[i], Pos('[IM1]',BaseDataCache.UserList[i]) + 5, Length(BaseDataCache.UserList[i]));

      ItemJSon.S['value']:= LValue;
      ItemJSon.S['label']:= LLabel;
      AJSon.AsArray.Add(ItemJSon);
    end;
  end;


What happens?

If i start typing a see a correct list of choises based on what i have typed.
However if i select one the Show text in the component is not the name but the Value set above
the code
Code: Select all
procedure TFrmMainAdmin.IWCGJQAutoCompleteJQAutoCompleteOptionsSelect(
  Sender: TObject; AParams: TStringList);
begin
  UserSession.IMSession.UserInfo := Aparams.Values['myuid'];
  ShowFrame(1000);
end;


Aparams.Values['myuid']; = 'Undefined'

I added this form to a new project. The old one is still working ok, so i'm missing something, but what?

Any help appreciated

Eric
etwoss
 
Posts: 1205
Joined: 06 Feb 2014 08:58

by Alexander Bulei » 01 Mar 2016 11:12

Hi Eric,

Nothing changed in this component.
The component always has this behavior...

If you want the label to be your text in input element, you should create the simple array of strings.

delphi code
for I := 0 to 9 do
begin
Item:= SO('Label ' + IntToStr(i+1));
AJSon.AsArray.Add(Item);
end;


Array of json object will have described behavior.

About this:

Code: Select all
 BrowerParam:= IWCGJQAutoComplete.JQAutoCompleteOptions.OnSelect.BrowserParams.Add;
 BrowerParam.ServerName:= 'myuid';
 BrowerParam.BrowserScript:= 'ui.item.uid';


and this

Code: Select all
Aparams.Values['myuid']; = 'Undefined'


It never works...because your json object have only label and value properties.
If you want make it work, change the BrowserScript:

Code: Select all
BrowerParam.BrowserScript:= 'ui.item.value';


Best Regards.
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

by etwoss » 01 Mar 2016 11:15

Hi

yes just found the problem:

ItemJSon.S['uid']:= LValue;

Thanks

Eric
etwoss
 
Posts: 1205
Joined: 06 Feb 2014 08:58


Return to JQAutoComplete

cron

Who is online

Users browsing this forum: No registered users and 1 guest

Contact Us.