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

Conditional Formatting and ReportItem.Value

4 Answers 557 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Steven Bunnell
Top achievements
Rank 1
Steven Bunnell asked on 17 Aug 2010, 06:12 PM
I have a TextBox that is calculating the difference in days between two dates.

Value: =IIF(Fields.originalshipdate>Fields.revisedshipdate, DateToInt(Fields.originalshipdate), DateToInt(Fields.revisedshipdate)) - DateToInt(now())
Format: {0:0}

public class OECReport : Telerik.Reporting.Report
{
    public static int DateToInt(DateTime date)
    {
        return date.Subtract(new DateTime(1899, 12, 31)).Days;
    }
}

This is returning an integer, in the range of -10 to 20, generally.

I am trying to use Conditional Formatting on this TextBox to Color the background based on the Value.

I've tried several different approaches without success.
----------------------------------------------------------
=ReportItem.Value < =0

Returns:

An error has occured while processing TextBox 'Alert':
Cannot perform '<' operation on System.String and System.Int32.

----------------------------------------------------------
=CInt(ReportItem.Value) < =0

An error has occured while processing TextBox 'Alert':
An error has occured while executing function CInt(). Check InnerException for further information.
------------- InnerException -------------
Exception has been thrown by the target of an invocation.
------------- InnerException -------------
Input string was not in a correct format.

----------------------------------------------------------
=ReportItem.Value < 0

Fires on all rows, regardless of Value.
----------------------------------------------------------

Your help on this matter is appreciated.

Steve

4 Answers, 1 is accepted

Sort by
0
Steven Bunnell
Top achievements
Rank 1
answered on 18 Aug 2010, 04:19 PM
Digging into this more, it appears that ReportItem.Value is returning the assigned "=IIF(Fields.originalshipdate>Fields.revisedshipdate, DateToInt(Fields.originalshipdate), DateToInt(Fields.revisedshipdate)) - DateToInt(now())"

As is the ReportItem.Text Property.

Browsing through the object during the Conditional Formatting execution, I do not see a property that contains the displayed/calculated Result.

Your help on this matter is appreciated.

Steve
0
Peter
Telerik team
answered on 19 Aug 2010, 04:09 PM
Hello Steven,

The Conditional Formating is being executed prior to the evaluation of the report item value. Thus the ReportItem.Value returns the expression itself that can not be casted to int and results in exception. Our suggestion in your case would be instead of =ReportItem.Value to use the value's expression = IIF(Fields.originalshipdate>Fields.revisedshipdate, DateToInt(Fields.originalshipdate), DateToInt(Fields.revisedshipdate)) - DateToInt(now())

Best wishes,
Peter
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
krisdoff
Top achievements
Rank 1
answered on 22 Oct 2019, 12:27 PM

I appreciate this a very old post, but I stumbled on it since I had the same expectations/issue. 

Obviously we can replace the ReportItem.Value with the actual formula that drives the Value, but I think the expectation is that we can reduce the duplication and as such increase reliability, i.e. it's easy to change the value and forget to update the logic in the formatting.

 

0
Neli
Telerik team
answered on 25 Oct 2019, 10:50 AM

Hi Chris,

You can try setting CalculatedFields of the DataSource where you can include the logic in the Expression instead of using the long formula. In this way, the duplication will be reduced and the performance will be increased.

Regards,
Neli
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Steven Bunnell
Top achievements
Rank 1
Answers by
Steven Bunnell
Top achievements
Rank 1
Peter
Telerik team
krisdoff
Top achievements
Rank 1
Neli
Telerik team
Share this question
or