Kendo Grid DetailTemplate, SubGrid Value Access Condition Expression

I have a Master / Child grid structure, for example:

Parent grid:

@(Html.Kendo().Grid<ElementViewModel>() .Name("gridEle") .Columns(cols => { cols.Bound(e => e.EleNum) }) .DataSource(dataSource => dataSource .Ajax() .Read(read => read.Action("GetElements", "Rating", pi)) ) .ClientDetailTemplateId("tempSubEle") ) 

Lattice for children as DetailTemplate:

  <script id="tempSubEle" type="text/kendo-tmpl"> @(Html.Kendo().Grid<SubElementViewModel>() .Name("gridSubEle_#=EleID#") .Columns(cols => { cols.Bound(e => e.Rating) .ClientTemplate("<input type='checkbox' value='1' " + "#if(Rating==1){#checked='checked'#}# />" ); }) .DataSource(dataSource => dataSource .Ajax() .Read(read => read.Action("GetSubElementsByElementID", "Rating", new {eID = "#=EleID#" })) ) .ToClientTemplate() ) </script> 

Problem:

I have the #if {# ... #} # operator in the ClientTemplate column, however the rating value is from the parent grid, not the current child grid (the parent grid has a column, also called โ€œratingโ€) to prove that it is from the parent grid, if I change the rating to a column that exists only in the Child grid, that is, SubEleID, it gives an error in the browser saying that SubEleID was not found.

Question:

and what is the syntax for the rating, gets the value of Child Grid? just to try, I even tried: data.Rating or $ (this) .Rating, nobody worked.

Please inform, thank you

+4
source share
1 answer

# in some template kendo is used for the parent property (for example, you use for the name: gridSubEle_#=EleID# , but for some child property you need to avoid # with \\ :

  cols.Bound(e => e.Rating) .ClientTemplate("<input type='checkbox' value='1' " + "\\#if(Rating==1){\\#checked='checked'\\#}\\# />" ); 
+7
source

All Articles