Some tricky custom binidng.

2 posts, 0 answers
  1. DoomerDGR8
    DoomerDGR8 avatar
    133 posts
    Member since:
    Aug 2010

    Posted 03 Mar 2011 Link to this post

    I'm at a point in a web project where, I need to bind a Telerik Grid with data. The data is retrieved on the basis of client ID and a date range. the data that is retrieved is to be bound with the grid but there is a twist. See attached file.

    The columns Actual Cost, Inv. Ref, Difference, Add Email, and Add Comment are not coming from DB. They are unbound as they do not exists. I can manage Add Email and Comment. However, once displayed to the user, the Actual Cost, Invoice Reference, and Difference columns are to be blank (row-wise, of course). When I enter something in Actual Cost against a row, the Difference column must show Est. Cost - Actual Cost. Also, the Est Cost, Actual Cost, and Difference are all currencies so having a Numerical input with two decimals is very desired. The Est. Cost is a bound column so masking is no issue there.

    The second noticable thing is that if the difference is in positive (and >= a certain defined limit), the row turns red. If difference is negative (and <= a certain limit), the row turns green.

    The page that is going to host this drama is a child page with the Ajax Proxy. The Grid will trigger Ajax on itself upon an action. Could someone giude me as to which event I shall subscribe on the grid and prevent grid auto operations? Also, I need to understand the moment the calculations (Difference = Est. Cost - Actual Cost) will occur... i.e., upon cell leave focus?

    Hassan Gulzar
  2. Marin
    Marin avatar
    1057 posts

    Posted 07 Mar 2011 Link to this post

    Hi Hassan,

    You can have a look at this demo showing similar calculations client-side. Basically OnBlur of the RadTextBox you can calculate the new value and set it to the corresponding cell of the grid. You can refer to this help article showing how to access cells client-side. There you can also format the cell (including fore color) by a certain criteria. You can also format the appearance of the negative and positive value if you use RadTextBox in a TemplateColumn (using EnabledStyle-ForeColor and NegativeStyle-ForeColor properties), it also allows currency formatting. When the RadTextBox is read only this can also be an alternative to the standard GridBoundCoumn that does not provide such special formatting.

    Kind regards,
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Back to Top