Jump to content

How to use ClientEvents to set background-color on parent TD


alfr

Recommended Posts


Hi, 

Still a newbie when it comes to javascript and ClientEvents... (Would appreciate some help from Serzod/DD or somebody else)

I've a form with a lot of TUniPanels (created dynamically with InsertControl. Layout=Table). On the panels are many tUniCheckboxes placed. As there are so many checkboxes I would like to change the background color on the parent TD when the checkbox is checked and cleared when the checkbox is not checked. See example where I've manually set one TD to background-color lightskyblue.

How can this be done with javascript and ClientEvents? (I suppose I need to add a javascript function that is called onchange or onchangevalue, but I'm not able to get the parentNode correctly etc..) There are also other functions that dynamically checks/unchecks the checkboxes, so important that the ClientEvent not only responds on onclick, but also when the other functions checks/unchecks.

image.thumb.png.40dfd5ad742c72407d38f60352af73ac.png

image.thumb.png.a308fba53209211f5c365b0d7ac26e08.png

Unigui version uni-1.70.0.1489 (desktop).

 

Link to comment
Share on other sites

Hello,

3 hours ago, alfr said:

where I've manually set one TD to background-color lightskyblue.

Is this acceptable to you?

1.

procedure ChBoxsChange(Sender: TObject);

procedure TMainForm.ChBoxsChange(Sender: TObject);
begin
  if (Sender as TUniCheckBox).Checked then
    (Sender as TUniCheckBox).Color := $00F9CD87
  else
    (Sender as TUniCheckBox).Color := clNone

end;

2. How to use, for example:

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  UniCheckBox1.OnChange := ChBoxsChange;
  UniCheckBox2.OnChange := ChBoxsChange;
  DynamicCheckBox.OnChange := ChBoxsChange;
end;

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...