Passing template expression and additional parameters

3 posts, 0 answers
  1. Blake
    Blake avatar
    18 posts
    Member since:
    Sep 2015

    Posted 21 Sep 2015 Link to this post

    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. Blake
    Blake avatar
    18 posts
    Member since:
    Sep 2015

    Posted 22 Sep 2015 Link to this post

    Excellent answer provided by Alexander Popov here
  3. Blake
    Blake avatar
    18 posts
    Member since:
    Sep 2015

    Posted 22 Sep 2015 in reply to Blake Link to this post

    http://www.telerik.com/forums/passing-template-expression-and-additional-parameters#Ipt9XHWxIUuvXSlnIdOnWA
Back to Top