Conditional Formatting and ReportItem.Value

5 posts, 0 answers
  1. Steven Bunnell
    Steven Bunnell avatar
    2 posts
    Member since:
    Sep 2009

    Posted 17 Aug 2010 Link to this post

    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
  2. Steven Bunnell
    Steven Bunnell avatar
    2 posts
    Member since:
    Sep 2009

    Posted 18 Aug 2010 Link to this post

    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
  3. Peter
    Admin
    Peter avatar
    1665 posts

    Posted 19 Aug 2010 Link to this post

    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
  4. krisdoff
    krisdoff avatar
    15 posts
    Member since:
    Nov 2006

    Posted 22 Oct in reply to Peter Link to this post

    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.

     

  5. Neli
    Admin
    Neli avatar
    190 posts

    Posted 25 Oct Link to this post

    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
Back to Top