Page 1 of 1

Changed behaviour

PostPosted: 01 Mar 2016 10:46
by etwoss
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

Re: Changed behaviour

PostPosted: 01 Mar 2016 11:12
by Alexander Bulei
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.

Re: Changed behaviour

PostPosted: 01 Mar 2016 11:15
by etwoss
Hi

yes just found the problem:

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

Thanks

Eric