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

Some tricky custom binidng.

1 Answer 25 Views
Grid
This is a migrated thread and some comments may be shown as answers.
DoomerDGR8
Top achievements
Rank 2
Iron
Iron
Iron
DoomerDGR8 asked on 03 Mar 2011, 02:06 PM
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?

Regards,
Hassan Gulzar

1 Answer, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 07 Mar 2011, 03:05 PM
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,
Marin
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!
Tags
Grid
Asked by
DoomerDGR8
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Marin
Telerik team
Share this question
or