Jump to content

Color one item in TUniRadioGroup


Mohammed Nasman

Recommended Posts

Just drop UniRadioGroup into form with UniButton, adding items at run time, add following code:

// just a a method to fill the UniRadioGroup(rgAnswers)
procedure TMainForm.AddAnswers;
begin
  rgAnswers.Items.Clear;
  rgAnswers.Items.Add('Answer 1');
  rgAnswers.Items.Add('Answer 3');
  rgAnswers.Items.Add('Answer 3');
  rgAnswers.ItemIndex := -1;

end;

procedure TMainForm.rgAnswersClick(Sender: TObject);
begin
  if rgAnswers.ItemIndex = 1 then
    rgAnswers.JSInterface.JSCode(#1'.queryById(1).el.setStyle("color", "blue");')
  else
    rgAnswers.JSInterface.JSCode(#1'.queryById(1).el.setStyle("color", "red");')
end;


procedure TMainForm.UniButton1Click(Sender: TObject);
begin
  AddAnswers
end;

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  AddAnswers
end;

it will work without a problem, go to Font property of the Form, set the font to bold, then try again, it will color the items for first time, then it will not work

 

Link to comment
Share on other sites

Can you try this?:

procedure TMainForm.rgAnswersClick(Sender: TObject);
begin
  if rgAnswers.ItemIndex = 1 then
    rgAnswers.JSInterface.JSCode(#1'.queryById(1).el.down(".x-form-cb-label-after").el.dom.style.color="blue";')
  else
    rgAnswers.JSInterface.JSCode(#1'.queryById(1).el.down(".x-form-cb-label-after").el.dom.style.color="red";')
end;
Link to comment
Share on other sites

  • 3 months later...
  • 10 months later...
On 8/23/2017 at 7:15 PM, Sherzod said:

Can you try this?:


procedure TMainForm.rgAnswersClick(Sender: TObject);
begin
  if rgAnswers.ItemIndex = 1 then
    rgAnswers.JSInterface.JSCode(#1'.queryById(1).el.down(".x-form-cb-label-after").el.dom.style.color="blue";')
  else
    rgAnswers.JSInterface.JSCode(#1'.queryById(1).el.down(".x-form-cb-label-after").el.dom.style.color="red";')
end;

Hi, this code not work in 1480. Get error  "O348.queryById(...) is null"

regards.

Link to comment
Share on other sites

Thank you very much.

I'll nearly goes mad :D  What is wrong ? I didn't see problem like this as long as my life :D 

S:= Format(#1'.items.getAt(' + IntToStr(GRP_.ItemIndex) +').el.down(".x-form-cb-label-after").el.dom.style.color="%s";',[uniColor2Web(clRed)]); // not work
S:= Format(#1'.items.getAt(%d).el.down(".x-form-cb-label-after").el.dom.style.color="%s";',[GRP_.ItemIndex, uniColor2Web(clRed)]);// not work
S:= Format(#1'.items.getAt(' + IntToStr(GRP_.ItemIndex) +').el.down(".x-form-cb-label-after").el.dom.style.color="%s";',[uniColor2Web(clRed)]);// not work
S:= Format(#1'.items.getAt(0).el.down(".x-form-cb-label-after").el.dom.style.color="%s";',[uniColor2Web(clRed)]); // WORK !!!!!!
GRP_.JSInterface.JSCode(S);

O348.items.getAt(...) is undefined

Link to comment
Share on other sites

Hi,

Sorry for the delay

 

23 hours ago, Freeman35 said:

S:= Format(#1'.items.getAt(' + IntToStr(GRP_.ItemIndex) +').el.down(".x-form-cb-label-after").el.dom.style.color="%s";',[uniColor2Web(clRed)]); // not work 
S:= Format(#1'.items.getAt(%d).el.down(".x-form-cb-label-after").el.dom.style.color="%s";',[GRP_.ItemIndex, uniColor2Web(clRed)]);// not work 
S:= Format(#1'.items.getAt(' + IntToStr(GRP_.ItemIndex) +').el.down(".x-form-cb-label-after").el.dom.style.color="%s";',[uniColor2Web(clRed)]);// not work 
S:= Format(#1'.items.getAt(0).el.down(".x-form-cb-label-after").el.dom.style.color="%s";',[uniColor2Web(clRed)]); // WORK !!!!!! GRP_.JSInterface.JSCode(S);

 

Where do you call these codes?

Link to comment
Share on other sites

No problem, I can understand you alone and try answer all forum.

That stringS for just  test,  problem is " getAt(0) " here. if give bigger then 0(zero), I mean,  getAt(1) or getAt(2) (ofcourse items added) get error.

code add button click. so form showed. maybe can important, form showed model.

regards

Link to comment
Share on other sites

On 11/1/2018 at 4:59 PM, Sherzod said:

Try this:


UniRadioGroup1.JSInterface.JSCode(#1'.items.getAt(0).el.down(".x-form-cb-label-after").el.dom.style.color="green";');

 

I'm sorry, It was wrong it seems:

Correct:

radioGroup.items.getAt...

  S:= Format(#1'.radioGroup.items.getAt(' + IntToStr(UniRadioGroup1.ItemIndex) +').el.down(".x-form-cb-label-after").el.dom.style.color="%s";',['green']);
  UniRadioGroup1.JSInterface.JSCode(S);

 

 

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