LovingMVC
LovingMVC

Reputation: 325

Conditionally adding a check box in Telerik MVC Grid

I am using Telerik Grid for MVC 3 with aspx engine. I have to add a check box only on those rows which status are completed.

 columns.Bound(grid => grid.CaseStatus).Width(80);

Above is my bound column now i have to check if CaseStatus value is some specific number then only i have to add check box with that row.

columns.Add(c => c.CaseID).Title("").Format("<input type='checkbox' />").Encoded(false).Width(5);

Any Idea how to do this?

Upvotes: 0

Views: 1595

Answers (1)

Nick
Nick

Reputation: 5872

You could use the ClientTemplate to achieve this:

Exmaple:

columns.Bound(p => p.CaseStatus).Title("Case Status").ClientTemplate("<#= (CaseStatus==true) ? '<input type='checkbox' />' : '' #>");

Templates allow you to customise the way the data is presented in the grid and you can use <#= #> to embed and compare databound expressions in a similar way to server side templates.

Upvotes: 2

Related Questions