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

[Solved] Define template based on condition

2 Answers 25 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.
Madzie
Top achievements
Rank 1
Madzie asked on 09 Feb 2013, 03:51 PM

In a grid, for the column Price, I would like to display the content of column value only if the property 'Status' != Constants.Invalid for that lineitem..

columns.Bound(p => p.Price).
Template(

@<text>

@if (item.Status.Equals(Constants.Invalid))

{

@Html.Label("")

}

else

{

@Html.Label(item.Price.ToString())

}

</text>

);
This doesn't seem to work ! It is still displaying the value of Price for all rows although one of them has item.Status=Constants.Invalid.

2 Answers, 1 is accepted

Sort by
0
Madzie
Top achievements
Rank 1
answered on 10 Feb 2013, 02:34 PM
any help please !
0
Petur Subev
Telerik team
answered on 13 Feb 2013, 04:11 PM
Hi,

 What kind of binding do you use? If it is Ajax binding then you should use ClientTemplate instead of the Template method.

Also this section shows how to create conditional template based on a value of a model.

Kind regards,
Petur Subev
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
Tags
Grid
Asked by
Madzie
Top achievements
Rank 1
Answers by
Madzie
Top achievements
Rank 1
Petur Subev
Telerik team
Share this question
or