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

Passing template expression and additional parameters

2 Answers 174 Views
Templates
This is a migrated thread and some comments may be shown as answers.
Blake
Top achievements
Rank 2
Blake asked on 22 Sep 2015, 02:51 AM

I have a hierarchy grid controlled by a TabStrip. I need to pass additional parameters, such as the TabStrip value, to the child Grid read action method.

For example

.Read(read => read.Action("HierarchyBinding_MetricGroups", "DataEntry", new { CategoryKey = "#=CategoryKey#", TabStip​Value = value}))​

I know you can pass parameters using a javascript function with

.Data("javascriptFunction")

But I am not sure how to pass the template expression to that function. 

Below is the code I am using​

<div id="dataEntryContainer">
    @(Html.Kendo().TabStrip()
        .Name("sitetabs")
        .Items(tabstrip =>
        {
            bool selected = true;
            foreach (var site in Model.Sites)
            {
                tabstrip.Add().Text(site.Name)
                    .Selected(selected)
                    .Content(@<text>
                    @(Html.Kendo().Grid(Model.Categorys)
                        .Name("grid_" + site.DisplayName)
                        .Columns(columns => { columns.Bound(c => c.Name).Title(""); })
                        .Events(events => events.DataBound("dataBound"))
                        .ClientDetailTemplateId("metricgroup-template")
                        .DataSource(dataSource => dataSource
                            .Ajax()
                            .Read(read => read.Action("HierarchyBinding_Categorys", "DataEntry"))
                        )
                    )
                </text>
                );
                selected = false;
              }
          })
          .Events(events => events.Select("onSelect"))
    )
</div>
  
<script id="metricgroup-template" type="text/kendo-tmpl">
    @(Html.Kendo().Grid<BalancedScorecardManagement.Models.vMetricGroup>()
            .Name("grid_#=CategoryKey#") // template expression, to be evaluated in the master context
            .Columns(columns =>
            {
                columns.Bound(m => m.MetricGroupLabel).Title("");
            })
            .DataSource(dataSource => dataSource
                .Ajax()
                .Read(read => read.Action("HierarchyBinding_MetricGroups", "DataEntry", new { CategoryKey = "#=CategoryKey#" }))
            )
            .Events(events => events.DataBound("dataBound"))
            .ClientDetailTemplateId("metric-template")
            .ToClientTemplate()
    )
</script>

2 Answers, 1 is accepted

Sort by
0
Blake
Top achievements
Rank 2
answered on 22 Sep 2015, 12:48 PM
Excellent answer provided by Alexander Popov here
0
Blake
Top achievements
Rank 2
answered on 22 Sep 2015, 12:49 PM
http://www.telerik.com/forums/passing-template-expression-and-additional-parameters#Ipt9XHWxIUuvXSlnIdOnWA
Tags
Templates
Asked by
Blake
Top achievements
Rank 2
Answers by
Blake
Top achievements
Rank 2
Share this question
or