This is a migrated thread and some comments may be shown as answers.

Is it possible to call CSS style programatically in Telerik Reports?

1 Answer 37 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Dennis Gundersen
Top achievements
Rank 1
Dennis Gundersen asked on 03 Nov 2009, 02:38 PM

 

Hi

I'm trying to fill a HTMLTextBox on a subreport programatically in order to change appearence depending on the data. I managed to get line breaks working by changing from BR to DIV tags, but I can't get the styles to work. Since I have a lot of subreports I really don't want to include FONT tags into the code and risk creating a maintenance nightmare. Is there a way to set styles programatically?

I've tried adding the HTML using a script that is called from the HTMLTextBox, such as
...
PositionLine = "<DIV Class='PositionCompany>'" & PositionLine & "</DIV>"
Return PositionLine

but this only gives me linebreaks, not the formatting. "'PositionCompany" is a style rule defined in the master report.

How do I call the CSS formatting? (By the way, I can't set it directly since I use several different style rules inside the same HTMLTextBoc depending on data.

Thanks in advance!

Re
Dennis

   Public Shared Function Position(ByVal Company As StringByVal City As StringByVal Country As StringByVal CompanyType As StringByVal Title As StringByVal DetailLong As StringByVal DetailShort As StringAs String 
 
        Dim PositionLine As String = Company.ToString  
 
        If City <> "" Then 
            If PositionLine <> "" Then 
                PositionLine += ", " & City.ToString  
            Else 
                PositionLine = City.ToString  
            End If 
        End If 
        If Country <> "" Then 
            If PositionLine <> "" Then 
                PositionLine += ", " & Country.ToString  
            Else 
                PositionLine = Country.ToString  
            End If 
        End If 
        If CompanyType <> "" Then 
            If PositionLine <> "" Then 
                PositionLine += " (" & CompanyType.ToString & ")" 
            Else 
                PositionLine = CompanyType.ToString  
            End If 
        End If 
        If PositionLine <> "" Then 
            PositionLine = "<DIV Class='PositionCompany'>" & PositionLine & "</DIV>" 
        End If 
        If Title <> "" Then 
            If PositionLine <> "" Then 
                PositionLine = PositionLine & "<DIV Class='PositionTitle'>" & Title.ToString & "</DIV>" 
            End If 
        End If 
        If DetailShort <> "" Then 
            If PositionLine <> "" Then 
                PositionLine = PositionLine & "<DIV Class='PositionDetails'>" & DetailShort.ToString & "</DIV>" 
            End If 
        End If 
 
        If DetailLong <> "" Then 
            If PositionLine <> "" Then 
                PositionLine = PositionLine & "<DIV Class='PositionDetails'>" & DetailLong.ToString & "</DIV>" 
            End If 
        End If 
 
 
        Return PositionLine  
 
    End Function 
 

1 Answer, 1 is accepted

Sort by
0
Accepted
Steve
Telerik team
answered on 05 Nov 2009, 12:02 PM
Hello Dennis,

You can achieve what you're after in a slightly different way by working insight the report only. You can review the Styling Reports help section that describes the available approaches for styling the report and items. So using this as your base you can alter the styles of an item depending on data either programmatically (e.g. ItemDataBound event) or create Conditional Formatting rules to handle this.

Sincerely yours,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
General Discussions
Asked by
Dennis Gundersen
Top achievements
Rank 1
Answers by
Steve
Telerik team
Share this question
or