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

How to format grid conditionally?

1 Answer 829 Views
Grid
This is a migrated thread and some comments may be shown as answers.
suhaib
Top achievements
Rank 1
suhaib asked on 28 Aug 2013, 01:29 PM
for following cases
- I am creating grid for Tests if failed then row style color should be read or passed then row style color should be green.
- Another thing is I want to create a runtime column which will be computed result from data
   example Completed is 9 and Total is 20: so I want to create column say Available which will be (20-9)=11

Thanks,
Suhaib

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 29 Aug 2013, 06:49 AM
Hello Suhaib,

Row styles can be set in two ways:

1) By using a row template with an IF statement inside

row template demo
http://demos.kendoui.com/web/grid/rowtemplate.html
http://docs.kendoui.com/api/web/grid#configuration-rowTemplate

how to use script statements inside a Kendo UI template
http://demos.kendoui.com/web/templates/expressions.html

or

2) By using the Grid's dataBound event to iterate through all rows, obtain each row's model and check the corresponding value

http://demos.kendoui.com/web/grid/events.html

the Grid's dataBound event fires when the widget is populated
http://docs.kendoui.com/api/web/grid#events-dataBound

the Grid's dataItem() method return a row model
http://docs.kendoui.com/api/web/grid#methods-dataItem

the model's get() method returns a value
http://docs.kendoui.com/api/framework/model#methods-get

===

A calculated column can be implemented with a column template with a script exression inside, or as part of the row template mentioned above.

http://docs.kendoui.com/api/web/grid#configuration-columns.template

Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
suhaib
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or