Jump to content

UniRadioGroup how to disable item


dpfmp

Recommended Posts

Hi,

I am trying to disable an item (index 3)  from a uniradiogroup with this code found here ( from Sherzod ) dated october 2017:

     UniRadioGroup1.JSInterface.JSAssign('radioGroup.items.getAt(3).disabled', [True])

It does not seem to be doing anything here with the latest version. Is there anything else I can try?

Thank you again.

 

Delphi 10.1 UniGui 1.50.0.1484

 

Link to comment
Share on other sites

27 minutes ago, dpfmp said:

I am trying to disable an item (index 3)  from a uniradiogroup with this code found here ( from Sherzod ) dated october 2017:

      UniRadioGroup1.JSInterface.JSAssign('radioGroup.items.getAt(3).disabled', [True])

 It does not seem to be doing anything here with the latest version. Is there anything else I can try?

Hi,

Use like this:

UniRadioGroup1.JSInterface.JSCall('radioGroup.items.getAt(3).setDisabled', [True]);

And remember that the index is Zero-based.

Link to comment
Share on other sites

Thank you Sherzod,

 

It still doesn't do anything.  

procedure TMainForm.UniButton1Click(Sender: TObject);
begin
  UniRadioGroup1.JSInterface.JSAssign('radioGroup.items.getAt(3).setDisabled', [True]);
end;

I have a UniRadioGroup with 10 items ( 0..  9) set a design time.. If i click the button, I still can select all the items.

Chrome V71  Firefox V65

Denis Prince

Link to comment
Share on other sites

  • 1 month later...
On 1/15/2019 at 4:57 PM, Sherzod said:

Hi,

Use like this:


UniRadioGroup1.JSInterface.JSCall('radioGroup.items.getAt(3).setDisabled', [True]);

And remember that the index is Zero-based.

 

Hi, I would like to know how I would check if a TUniRadioGroup item is enabled.

Link to comment
Share on other sites

20 minutes ago, Bruno Ruiz said:

Hi, I would like to know how I would check if a TUniRadioGroup item is enabled.

Hello, 

Can you please specify which edition and build of UniGUI are you using? 

Link to comment
Share on other sites

2 hours ago, Sherzod said:

Please adjust your forum email address:

 

Hello Sherzod, this is Bruno Ruiz, we registered the account as you requested, and we will use this account as of now ...

could we help us with how to check if a TUniRadioGroup item is enabled?

Thank you!

Link to comment
Share on other sites

16 minutes ago, DEV_THS said:

Hi, I would like to know how I would check if a TUniRadioGroup item is enabled.

Hi,

Sorry for the late reply.

Can you create an array (the size of which is equal to the count of items) on the server side and set and get the values depending on the execution of the JS code?!

Link to comment
Share on other sites

11 minutes ago, Sherzod said:

Hi,

Sorry for the late reply.

Can you create an array (the size of which is equal to the count of items) on the server side and set and get the values depending on the execution of the JS code?!

266/5000
 
Hi, it's okay ... thanks for the reply!

I'm starting, could you give me a simple example of how to proceed this way?

Need to do something like this in VCL

procedure TUniform1.radioGroup2Click(Sender: TObject);
begin
   radioGroup1.Buttons [0] .Enabled: =
     radioGroup1.Buttons [0] .Enabled and MyCondition;
end;
Link to comment
Share on other sites

44 minutes ago, DEV_THS said:

could you give me an example of how to solve this problem?

procedure TUniform1.radioGroup2Click(Sender: TObject);
begin
     radioGroup1.Buttons [0] .Enabled: =
     radioGroup1.Buttons [0] .Enabled and MyCondition;
end;

Something like this:

1. 

  private
    { Private declarations }
    FButtonsArray: array of Boolean;

2.

procedure TMainForm.UniFormCreate(Sender: TObject);
var
  I: Integer;
begin
  SetLength(FButtonsArray, UniRadioGroup1.Items.Count);
  for I := Low(FButtonsArray) to High(FButtonsArray) do
    FButtonsArray[I] := True;

end;

3.

procedure TMainForm.UniButton2Click(Sender: TObject);
begin
  UniRadioGroup1.JSInterface.JSCall('radioGroup.items.getAt(3).setDisabled', [True]);
  FButtonsArray[3] := False;
end;

4.

procedure TMainForm.UniButton3Click(Sender: TObject);
begin
  if FButtonsArray[3] then
    ShowMessage('True')
  else
    ShowMessage('False');

end;

 

Link to comment
Share on other sites

4 hours ago, Sherzod said:

Something like this:

1. 


  private
    { Private declarations }
    FButtonsArray: array of Boolean;

2.


procedure TMainForm.UniFormCreate(Sender: TObject);
var
  I: Integer;
begin
  SetLength(FButtonsArray, UniRadioGroup1.Items.Count);
  for I := Low(FButtonsArray) to High(FButtonsArray) do
    FButtonsArray[I] := True;

end;

3.


procedure TMainForm.UniButton2Click(Sender: TObject);
begin
  UniRadioGroup1.JSInterface.JSCall('radioGroup.items.getAt(3).setDisabled', [True]);
  FButtonsArray[3] := False;
end;

4.


procedure TMainForm.UniButton3Click(Sender: TObject);
begin
  if FButtonsArray[3] then
    ShowMessage('True')
  else
    ShowMessage('False');

end;

 

I understood, I imagined something like this, but I thought I could have something simpler ...

but solves my problem, thank you very much for Sherzod's attention and sorry for the inconvenience.

Link to comment
Share on other sites

On 3/22/2019 at 2:53 PM, Sherzod said:

OK, no problem

Thank you

Hi Sherzod, how are you?

I believe that I came across a bug, could you help me?

I have a method in which I rename run-time items from a UniRadioGroup

but I noticed that when I rename this item, and try to disable any item by its index, this command is not matched.

I already have in my form a rgOrdem = TuniRadioGroup created in Design with 3 items.

and at some point I call my method EnableOrdenacao;

example:
procedure TUniForm1.EnableOrdenacao;
begin
   rgOrdem.Items [0]: = 'By Description';
   rgOrdem.Items [1]: = 'By Code';
   rgOrdem.Items [2]: = 'By Date';

   case rgTypeRelatory.ItemIndex of
     7.8:
     begin
       if rgTypeReport.ItemIndex = 8 then
         rgOrdem.Items [0]: = 'By Business Name';

       rgOrdem.Items [1]: = 'By Code Desc.';
       rgOrdem.JSInterface.JSCall ('radioGroup.items.getAt (' + IntToStr (2) + '). setDisabled', [True]);
     end;
   end
  
end;

 

Thank you!

Link to comment
Share on other sites

16 minutes ago, DEV_THS said:

I'll be waiting

Try with defer:

...
rgOrdem.Items[1] := 'By Code Desc.';
rgOrdem.JSInterface.JSCode('Ext.defer(function(){'#1'.radioGroup.items.getAt(' + IntToStr (2) + ').setDisabled(true)}, 100);');
...

 

Link to comment
Share on other sites

13 minutes ago, Sherzod said:

Try with defer:


...
rgOrdem.Items[1] := 'By Code Desc.';
rgOrdem.JSInterface.JSCode('Ext.defer(function(){'#1'.radioGroup.items.getAt(' + IntToStr (2) + ').setDisabled(true)}, 100);');
...

 

Cool, it worked ...

Thank you Sherzod for your help and for the speed ...

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