function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SFDC_LearnerSFDC_Learner 

Bold text from apex class

Hi I have a list of records that i am displaying in visual force page like below

 

code        Name

 

A001         Test1

A002          Test2

A003          Test3

 

 

Is there any possibility to make a text as bold from the apex class. Suppose for "A002", can i show this value in bold text??

liron169liron169
You can't do it in the apex class.

it should be done in VF page. Simply add the text you want in bold
inside:
<b> BOLD TEXT</b>
jreehjreeh

If you know ahead which values will be bold(meaning no custom logic in apex), then it would be best to use  style="font-weight:bold;" and hardcode this style into your visualforce.

 

But if you require custom logic within apex to determine if it will be bold or not

There is a way to do it through Apex with a Wrapper Class, but it is not really recommended.

 

Basically you would wrap the data as so. 

 

String aTest, Boolean bBoolean

 

1) Test1, false

2) Test2, true (for bold)

3) Test3, false

 

Then in the Visualforce page you would render the style based on if it was true or false. (you would use an if/else in visualforce)

I have done this before, but I honestly wouldnt recommended unless it is absolutely necessary.