Reputation: 51063
I am trying to configure a Kendo Grid column to display and edit a TimeSpan?
property (yeah, I know...), but to do do I have mapped the TimeSpan?
to a simpler TimeOfDay
model, with just Hours
, Minutes
, and Seconds
properties.
I have gleaned little from the Kendo documentation, which in itself is, no other words describe it, pathetic; worthy only of some sloppy little open source project, but relies on forum questions and answers. In other words, only document what people ask, and at that, rely on the free help of forum members. Rant over.
My column definition looks like this:
columns.Bound(p => p.StartTime).ClientTemplate("#if (StartTime != null) {#= Hours + ':' + Minutes #} else {#= '' #} #");
The output from that is
= Hours ':' Minutes
for non-null values and
= ''
for null values.
Please, for the love of God, someone tell me what I'm doing wrong, and as a bonus, refer me to an explanation, not a bunch of bloody unsuitable examples labelled 'Documentation'.
Upvotes: 2
Views: 2972
Reputation: 30661
The template definition is invalid because the starting # isn't closed. You can try with this:
"#if (StartTime != null) { # #= Hours # : #= Minutes # #} else {# #}#"
It would be easier to explain if it is split on multiple rows:
"# if (StartTime !=null) { #" +
"#= Hours # : #= Minutes #" +
"# } else { #" +
" " +
"# } #"
The the # code #
statement is used to embed executable JavaScript code which doesn't output anything. The #= code #
statement is used to output raw values (no HTML encoding). The #: code #
statement will html encode the output.
Here is a live demo: http://jsbin.com/ecunuh/1/edit
Upvotes: 2