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

Conditional Formatting in StyleRule?

3 Answers 485 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
jacob
Top achievements
Rank 1
jacob asked on 14 Dec 2011, 07:46 PM
Is it possible to set conditional formatting within a StyleRule? I am attempting to set the background of an alternating row and want to avoid setting the conditional formatting repeatedly. If there is a way to loop through the rows in the code behind and set the conditional formatting based on row index, that would work too. (For example, change Style name from GridRow to AltGridRow if Mod2.)

Any help would be greatly appreciated. I am a little new to the control suite so I appreciate the patience!

Thanks,

Jake

3 Answers, 1 is accepted

Sort by
0
jacob
Top achievements
Rank 1
answered on 14 Dec 2011, 08:34 PM
Mr. Telerik: While I have your attention....

It seems as though I have more issues. If I run the report, I get an object reference error (stack trace is below). When I try to select a column, I get an that reads "Cannot select a cell with no report item." I tried to delete the column. When doing so, I get a object reference error from Visual Studio. The designer seems extremely buggy...almost like an alpha release. I'm guessing I will need to manually fix somehting in the .designer.vb file...but what? I don't see any columns with a width less than 0.


[NullReferenceException: Object reference not set to an instance of an object.]
   Telerik.Reporting.Processing.Table.MeasureColumns(Graphics graphics) +298
   Telerik.Reporting.Processing.Table.Measure(MeasureDirection dir, Graphics graphics) +58
   Telerik.Reporting.Processing.ProcessingElement.MeasureElement(MeasureDirection dir, Graphics graphics) +128
   Telerik.Reporting.Processing.ProcessingElement.Measure(MeasureDirection dir, Graphics graphics) +1291
   Telerik.Reporting.Processing.ReportSectionBase.Measure(MeasureDirection dir, Graphics graphics) +40
   Telerik.Reporting.Processing.ProcessingElement.MeasureElement(MeasureDirection dir, Graphics graphics) +128
   Telerik.Reporting.Processing.Group.MeasureElement(MeasureDirection dir, Graphics graphics) +208
   Telerik.Reporting.Processing.Report.MeasureElement(MeasureDirection dir, Graphics graphics) +358
   Telerik.Reporting.Processing.Report.MeasureElement(ProcessingElement elementToMeasure) +201
   Telerik.Reporting.Processing.Report.Process(DataMember data, DataItemState state, Boolean interactivityEnabled, Boolean documentMapEnabled, IImageCache imageCache) +146
   Telerik.Reporting.Processing.ReportProcessor.ProcessReport(IReportDocument reportDocument, IDictionary processingContext) +1242
   Telerik.Reporting.Processing.ReportProcessor.RenderReport(String format, IReportDocument reportDocument, Hashtable deviceInfo, Hashtable renderingContext, CreateStream createStreamCallback) +492
   Telerik.ReportViewer.WebForms.ReportRenderOperation.RenderReport(String format, IReportDocument reportDocument, Hashtable deviceInfo, Hashtable renderingContext, CreateStream createStreamCallback) +82
   Telerik.ReportViewer.WebForms.ReportPageOperation.RenderReport(String format, IReportDocument reportDocument, Hashtable deviceInfo, Hashtable renderingContext) +196
   Telerik.ReportViewer.WebForms.ReportRenderOperation.PerformOperationOverride() +155
   Telerik.ReportViewer.WebForms.ReportPageOperation.PerformOperationOverride() +49
   Telerik.ReportViewer.WebForms.HandlerOperation.PerformOperation(HttpContext context, ICacheManager cacheManager) +68
   Telerik.ReportViewer.WebForms.BasicHandler.ProcessRequest(HttpContext context) +241
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
0
Elian
Telerik team
answered on 16 Dec 2011, 04:01 PM
Hi Jacob,

  1. If I understand you correctly you want alternating row style. If that is the case you can apply conditional formatting to the item that repeats (if you put items in the detail section, you apply conditional formatting to the detail section, if you use table, to the table row). Using the the expression "RowNumber()%2==1" will automatically give you the alternating row style. See our List Bound demo which implements this approach.

    If you want to apply the same condition to more than one report object, you can do it all at once. Just select all the items you need (holding control), right-click on any of them and select Conditional Formatting. Once you are done, the conditional formatting will be applied to all the items you have selected.

  2. It looks like the column group is missing it's report item (which plays the role of a table header cell). It might be deleted or not set. Does this happen when you create new table (without modifying the code-behind manually)?
    If so, please open a support ticket and attach a project that exposes the problem for further investigation.

Greetings,
Elian
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

0
jacob
Top achievements
Rank 1
answered on 16 Dec 2011, 04:40 PM
Thanks for the response in regards to the conditional formatting. That is pretty obvious and my apologies for a fairly stupid question. I was trying to apply a StyleName based on a condition...but your approach works, although not quite as ideal.

I did get this error while working with the formatting of the controls in the table (setting textbox fonts, backgrounds. conditional formatting, etc...) but I do not recall exactly what happened. All I can say is the table appeared to be laid out fine and I had not modified any code within the .designer.vb file prior to receiving this error. There were 18 columns and I received this error for items 4, 5, 6 and 7. There were no floating controls or columns. Unfortunately, I had to quickly fix the issue for a demo and didn't have time to wait on the support. I ended up deleting the table and completely rebuilding it. If this occurs again, hopefully I will have a little more time to debug and preserve the issue for ticket opening purposes.
Tags
General Discussions
Asked by
jacob
Top achievements
Rank 1
Answers by
jacob
Top achievements
Rank 1
Elian
Telerik team
Share this question
or