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

Conditional ClientTemplate on Grid in MVC

1 Answer 1215 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ian
Top achievements
Rank 2
Ian asked on 16 Jul 2013, 08:39 PM
My Model has a Datetime that comes as a null sometimes. This renders as 1/1/0001

I can't edit the Model.

Is there a way to put in a condition in the Client Temple so that nulls are not displayed, something like this??

@(Html.Kendo().Grid(Model.Items as IEnumerable<XYZ>)
        .Name("KendoCrGrid")
       .Columns(columns =>
                {
                columns.Bound(e => e.SignUpDate).ClientTemplate("#= <condition> ? kendo.toString(date, 'MM/dd/yyyy')#");

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimiter Madjarov
Telerik team
answered on 17 Jul 2013, 06:20 AM
Hello Ian,


Yes, you could perform this type of check exactly the same way. For example:

"#= (date == null) ? ' ' : kendo.toString(date, 'MM/dd/yyyy') #"

I wish you a great day!

Regards,
Dimiter Madjarov
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
Ian
Top achievements
Rank 2
Answers by
Dimiter Madjarov
Telerik team
Share this question
or