vb.net - Output alternate field in case bound field is null on a Kendo MVC Grid ClientTemplate -
i have cell in kendo mvc grid i'd take 1 of 2 data fields depending on value of one:
@(html.kendo().grid(of rtfvm)().name("realtimefinancials") _ .columns(sub(c) c.bound(function(x) x.line.lineitem).htmlattributes(new {.style = "text-align:left"}) c.bound(function(x) x.line.months(0).total).format("0:#,##0}").clienttemplate("#if(data.line.months[0].message == null) {data.line.months[0].total} else {data.line.months[0].message} #") end sub) _ etc
the cell rendering blank every time regardless of result of null comparison. must missing obvious!
the #...# template markup executes js not output anything.
instead, try #:...# or #=...# both output value html, or template:
#if(data.line.months[0].message == null) {##:data.line.months[0].total##} else {##:data.line.months[0].message##}# (it looks weird on 1 line, if insert line breaks make more sense:)
#if(data.line.months[0].message == null) {# #:data.line.months[0].total# #} else {# #:data.line.months[0].message# #}# i think template might work:
#: data.line.months[0].message ?? data.line.months[0].total # which use null-coalescing operator use total in case message falsey.
Comments
Post a Comment