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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...