Jump to content

fieldset checkboxtoggle: how to determine from code if user click/check the toggle (expanded)?


fraxzi

Recommended Posts

On 6/28/2021 at 10:45 AM, fraxzi said:

This FieldSet has CheckboxToggle = true, when uncheck/check at runtime, i'd like to capture when it expand/collapse.

Hello,

Sorry for the late response.

You can use ClientEvents.

UniFieldSet1 -> ClientEvents -> ExtEvents ->

function collapse(fieldset, eOpts)
{
    ajaxRequest(this, '_collapse', ['collapsed='+true]);
}
function expand(fieldset, eOpts)
{
    ajaxRequest(this, '_collapse', ['collapsed='+false]);
}
procedure TMainForm.UniFieldSet1AjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
begin
  if EventName = '_collapse' then
    if Params.Values['collapsed'].ToBoolean then
      ShowMessage('collapsed')
    else
      ShowMessage('expanded')

end;

 

Link to comment
Share on other sites

8 hours ago, Sherzod said:

Hello,

Sorry for the late response.

You can use ClientEvents.

UniFieldSet1 -> ClientEvents -> ExtEvents ->


function collapse(fieldset, eOpts)
{
    ajaxRequest(this, '_collapse', ['collapsed='+true]);
}

function expand(fieldset, eOpts)
{
    ajaxRequest(this, '_collapse', ['collapsed='+false]);
}

procedure TMainForm.UniFieldSet1AjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
begin
  if EventName = '_collapse' then
    if Params.Values['collapsed'].ToBoolean then
      ShowMessage('collapsed')
    else
      ShowMessage('expanded')

end;

 

Hi @Sherzod,

Works great!

Then can I expand the fieldset if I have a field with true value?

Thanks,

Frances

Link to comment
Share on other sites

13 hours ago, Sherzod said:

procedure TMainForm.UniButton1Click(Sender: TObject);
begin
  UniFieldSet1.JSInterface.JSCall('expand', []);
  //UniFieldSet1.JSInterface.JSCall('collapse', []);
end;

 

Hi @Sherzod,

Works like magic! Thanks much for the great support.

now I can reduce the screen clutter for cleaner look.

 

Regards,

Frances

  • Like 1
Link to comment
Share on other sites

  • 1 year later...

Hi @Sherzod

I'd like to change from this: (Collapsible, CheckboxToggle)

image.png.ec2661fdb8b6a580dc6e4dc9ac077e2e.png

To this: (no more CheckboxToggle) -> programmatically like if I chick a button.

image.png.808b41161b477d7cc20b4671eca5e86b.png

I tried fieldset.checkboxtoggle := false or with fieldset.collapsible := false, but not success.

I hope you can suggest how to do it.

Thanks,

Frances

 

Link to comment
Share on other sites

On 3/22/2023 at 5:20 AM, fraxzi said:

I tried fieldset.checkboxtoggle := false or with fieldset.collapsible := false, but not success.

Maybe you will try this solution?

procedure TMainForm.UniButton1Click(Sender: TObject);
begin
  UniFieldSet1.Collapsible := not UniFieldSet1.Collapsible;

  with UniFieldSet1 do
    if CheckboxToggle then
      if Collapsible then
      begin
        JSInterface.JSCall('checkboxCmp.show', []);
        JSInterface.JSCall('getEl().down(".x-fieldset-header-text").resumeEvent', ['click']);
      end
      else
      begin
        JSInterface.JSCall('checkboxCmp.hide', []);
        JSInterface.JSCall('getEl().down(".x-fieldset-header-text").suspendEvent', ['click']);
      end;

end;

 

  • Like 1
Link to comment
Share on other sites

17 hours ago, Sherzod said:

Maybe you will try this solution?

procedure TMainForm.UniButton1Click(Sender: TObject);
begin
  UniFieldSet1.Collapsible := not UniFieldSet1.Collapsible;

  with UniFieldSet1 do
    if CheckboxToggle then
      if Collapsible then
      begin
        JSInterface.JSCall('checkboxCmp.show', []);
        JSInterface.JSCall('getEl().down(".x-fieldset-header-text").resumeEvent', ['click']);
      end
      else
      begin
        JSInterface.JSCall('checkboxCmp.hide', []);
        JSInterface.JSCall('getEl().down(".x-fieldset-header-text").suspendEvent', ['click']);
      end;

end;

 

Hi @Sherzod,

The Guro strikes again!  ... you always amaze me (us).

works perfectly.

Thanks,

Frances

  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...