CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

Problem with first value

by Joelzim » 28 Jan 2018 23:37

I am creating a dropdown with the following.

If I have any items in the drop down the first value is always selected. I need to allow the user to not select anything or somehow display a blank value when it is not selected. The Allow clear does not seem to work.

lCb := TIWCGJQDropDown.Create(aComponentOwner);
lCb.Parent := aComponentParent;
lCb.Name := 'dynmcompDlgMstrUDF0';
lCb.Visible := True;
lCb.Enabled := True;
lCb.JQDropDownOptions.Multiple := False;
lCb.JQDropDownOptions.AllowClear := True;
lCb.DataLink.DataSource := aMstrDS;
lCb.DataLink.FieldName := 'SHORT_DESC';
lCb.Height := h_size;
lCb.Width := w_size;
lCb.Top := top_pos;
lCb.Left := left_pos_comp;
lCb.ZIndex := z_indx;
lStrList := TStringList.Create;
try
lStrList.Delimiter := ';';
lStrList.DelimitedText := FieldbyName('SHORT_VAL').AsString;
fxStrListToCGDropDownList(lStrList,lCB);
finally
lStrList.Free;
end;
Joelzim
 
Posts: 31
Joined: 29 Jul 2017 06:17

by Joelzim » 29 Jan 2018 04:40

I tried JQDropDownOptions.Placeholder := ' '; from another post but it does not work either.
Joelzim
 
Posts: 31
Joined: 29 Jul 2017 06:17

by Joelzim » 29 Jan 2018 04:48

If I add

with lCb.items.add do
begin
Caption := '';
value := '';
end;

Then it will kinda give me a blank value. I am not sure how to achieve a blank value
Joelzim
 
Posts: 31
Joined: 29 Jul 2017 06:17

by Joelzim » 29 Jan 2018 05:38

I think I got it working with the following.

lCb.JQDropDownOptions.Placeholder := '-- No Selection --';

However, there is one thing that does not quite work as expected with the following senario

If you have a value in the database and the dropdown is connected to a certain field, then when you edit the record the allowclear x is not seen. You have to select the dropdown value again before you see the x and can clear out the dropdown and set it back to blank.
Joelzim
 
Posts: 31
Joined: 29 Jul 2017 06:17

by Joelzim » 29 Jan 2018 06:24

Now I have one more issue.

The values that are selected in the dropdown box are saved in the database but when you try to reedit the record the dropdown does not show what is already selected in the database.

Do i need to do something like the following? I would think not since the dropdown is data aware.


lCb.Val := aMstrDS.DataTable.fieldbyname('FLAG_LIST').asstring;
Joelzim
 
Posts: 31
Joined: 29 Jul 2017 06:17

by Alexander Bulei » 29 Jan 2018 10:47

Hi Joelzim,

Please send us the simple testcase project.
TIA

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 Joelzim » 30 Jan 2018 04:04

I got it working by setting

lCb.JQDropDownOptions.Placeholder := '-- No Selection --'

after I populated the options in the dropdown. (not before)
Joelzim
 
Posts: 31
Joined: 29 Jul 2017 06:17


Return to JQDropDown

cron

Who is online

Users browsing this forum: No registered users and 1 guest

Contact Us.