asp.net mvc - Use Model object value in Client template Telerik Grid mvc -
i need display 2 different values in grid based on model object property.i able using template not client template. how it?
i have used below code getting error iscontractorpo undefined.
@{ model.iscontractorpo = "p"; } <div> @{html.telerik().grid(model.testlist) .name("testgrid") .columns(columns => { columns.bound(col => col.fte); columns .template(@<text>@if (model.iscontractorpo == "c") {<div>@item.fte</div>} else if (model.iscontractorpo == "p") {<div>-</div>}</text>).title("ftetestcolumn") .clienttemplate("<# if (model.iscontractorpo == 'c') { #> <div><#=fte#></div><# } else if(model.iscontractorpo == 'p'){ #><div>-</div><# } #>"); columns.bound(col => col.balanceamount); columns.bound(col => col.balanceunits); }) .clientevents(events => events.ondatabinding("ondatabinding")) .render(); } </div>
after sometime of analysis, came know can use model property in client template making script variable. following code solved issue.
<script type="text/javascript"> var iscontractorpo = '@model.iscontractorpo'; </script>
and client template
clienttemplate("<# if (iscontractorpo == 'c') { #> <div><#=fte#></div><# } else if(iscontractorpo == 'p'){ #><div>-</div><# } #>");
Comments
Post a Comment