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

Specific syntax to get parent field values for comparison?

1 Answer 98 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 28 Feb 2013, 10:37 PM

I have a Kendo grid that displays the Grid with Details being a Tab.  The first tab basically renders a different partial view based on the Row's StatusID column.  The "if" condition within the .Content() method of the tab item script in the template just does not work.  The if condition is always false and falls into the “else” block.  Is there a specific syntax to get the parent field's value to compare? I tried using the escape characters \\ before the pre-processor character #

 

Thanks!

 

    @(Html.Kendo().Grid(Model)

    .Name("Grid")   

    .Columns(columns =>

    {

        columns.Bound(p => p.Name).Groupable(false);

        columns.Bound(p => p.StatusName).Width(100);       

        columns.Bound(p => p.Description).Title("Description").Width(150);

        columns.Bound(p => p.City).Width(100);

        columns.Bound(p => p.State).Width(70);

        columns.Bound(p => p.AssignedTo);

        @*

        columns.Command(command => command.Custom("View Details").Click("showDetails"));

        *@

 

    })

        .ClientDetailTemplateId("detailsTemplate")

        .Pageable()

        .Sortable()

        .Scrollable(src => src.Height(500))

        .Filterable()

             .DataSource(dataSource => dataSource

                .Ajax()

                .Read(read => read.Action("ViewDetails", "Site"))

                .PageSize(20)

             )

             .Events(events =>

                    {

                        events.DataBound("dataBoundDetails");

                        events.DetailExpand("expandDetails");

                    })

    )

@(Html.Kendo().Window().Name("Details")

        .Title("Site Details")

    .Visible(false)

    .Modal(true)

    .Draggable(true)

    .Width(500)

)

 

<script id="detailsTemplate" type="text/kendo-tmpl">

   

    @(Html.Kendo().TabStrip()

            .Name("TabStrip_#=Id#")

            .SelectedIndex(0)           

            .Items(items =>

            {  

                //Main            

                items.Add()

                    .Text("Details")

                    .Encoded(false)                 

                    .Content(@<text>

                    @if("#= StatusId #" == "1")

                    {                                     

                        @Html.Action("SiteRequestView", "Site")

                       

                    } 

                    else

                    { 

                        @Html.Action("EvaView", "Site")

                    }

 

                    </text>);                                                          

               })

            .ToClientTemplate())

</script>

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 04 Mar 2013, 04:24 PM
Hi,

The data will be loaded on the client when using Ajax binding so a client template expression should be used instead e.g.

items.Add()
    .Text("Details")
    .Encoded(false)   
    .Content(
        "#if(StatusId == '1') {#  " +                          
            Html.Action("SiteRequestView", "Site") +
        "#} else {#" +
            Html.Action("EvaView", "Site") +
        "#}#"
    );
Kind regards,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Eric
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or