Jump to content

Change tabsheet font color with different condition


allenchow

Recommended Posts

Is it possible to change the font color of tabsheet for different condition? e.g. when some value > 0 or value = 0

 

I've tried using something like :

 

  if s > 0 then
     UniSession.AddJS(UniTabSheet4.JSName + '.tab.btnInnerEl.setStyle("color", "#008000")')
  else
     UniSession.AddJS(UniTabSheet4.JSName + '.tab.btnInnerEl.setStyle("color", "#000080")');
 
But it will show error : 
 

Cannot read property 'btnInnerEl' of undefined


Cannot read property 'btnInnerEl' of undefined

Link to comment
Share on other sites

The latest build.

 

I think the problem is I put the code under a table afterscroll and check the value of current records. 

Maybe there are too many records inside the table, it gives me the error, and I dound the error contents are very long (with all record datas inside ) !!!

Link to comment
Share on other sites

In your case a dirty workaround:

procedure TMainForm.ClientDataSet1AfterScroll(DataSet: TDataSet);
begin
  try
    if ClientDataSet1.FieldByName('TaxRate').AsInteger = 0  then
       UniSession.AddJS('try {' + UniTabSheet1.JSName + '.tab.btnInnerEl.setStyle("color", "#008000")} catch(err){}')
    else
       UniSession.AddJS('try {' + UniTabSheet1.JSName + '.tab.btnInnerEl.setStyle("color", "#000080")} catch(err){}');
  except
     //
  end;

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