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

[Solved] Conditional column formatting with ajax binding

2 Answers 168 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Patrick Rubeski
Top achievements
Rank 1
Patrick Rubeski asked on 24 Jun 2010, 02:26 PM
the Grid demos state that conditional column formatting is not available when using ajax binding.  I have a need for this and wondered if this was in the road map, and if so when it can be expected.
thanks for any information,
Patrick.

2 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 24 Jun 2010, 04:41 PM
Hi Patrick Rubeski,

This is not in the roadmap nor will it ever be. The reason is simple - conditional server formatting code is executed on the server side whilst ajax binding occurs on the client side.

Fortunately a very simple workaround exists - use JavaScript to perform the formatting. To do so use the OnRowDataBound client event. Then use data from data item and style as appropriate. Here is a short example:

function onRowDataBound(e) {
     var dataItem = e.dataItem;
     var row = e.row;
     if (dataItem.Freight > 100) {
          row.cells[0].style.color = 'red';
     }
}



I hope this helps,
Atanas Korchev
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
Alex
Top achievements
Rank 1
answered on 26 Jan 2012, 01:30 PM
Atanas, thank you for the explanation.  Can someone please update the online Custom Formatting page with this explanation and a link or demo for client side formatting.  The way it's worded now makes it sound like you will support ajax binding formatting in the future, and it's not even possible to custom format at all yet.  It will save others in the future some time to have the information from this post on the demo page.  Thank you.
Tags
Grid
Asked by
Patrick Rubeski
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Alex
Top achievements
Rank 1
Share this question
or