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

Url.Action in hierarchy grid problem

1 Answer 287 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 2
Dan asked on 01 Jul 2014, 08:42 PM
I have the following hierarchy grid that is server bound.  In the DetailTemplate I have tried 2 columns containing a Url.Action link.  The .ClientTemplate column does not render to the page as an anchor.  The .Template column has a syntax error at the @<text>.  How can I get a Url.Action column to render in the expansion hierarchy?

Thanks.
Dan

Code:
@model IEnumerable<EquipmentsSummary>
 
<div class="info-row">
    @(Html.Kendo().Grid(Model)
        .Name("EquipmentGrid")
        .Columns(columns =>
        {
            columns.Bound(e => e.ID).Hidden();
            columns.Bound(e => e.PatientId).Hidden();
            columns.Template(@<text>
                <a href="@Url.Action("EquipmentSettingEdit", Controllers.Employee, new { equipmentid=item.ID, settingid=0 }) "class='btn btn-sm'>Add</a>
                </text>).Width(75).Title("Add<br />Setting");
            columns.Bound(e => e.EquipName).Title("Item Name");
            columns.Bound(e => e.SerialNo).Title("Serial #");
            columns.Bound(e => e.AssetStatus).Title("Status");
            columns.Bound(e => e.AssetStatusDate).Title("Date");
        })
        .HtmlAttributes(new { style = "height: 500px;" })
        .Pageable(pageable => pageable
            .PageSizes(true).PageSizes(new int[] { 20, 50, 100 })
            .ButtonCount(5))
        .Sortable()
        .Filterable()
        .Scrollable()
        .DataSource(dataSource => dataSource.Server()
            .PageSize(20))
        .DetailTemplate(
            @<text>
                @(Html.Kendo().Grid(item.SettingItems)
                    .Name("Settings_" + item.ID)
                    .Columns(columns =>
                    {
                        columns.Bound(s => s.SettingID).Hidden();
                        columns.Bound(s => s.EffectiveDate).Title("Date").Format("{0:g}");
                        columns.Bound(s => s.AssetStatus).Title("Status");
                        columns.Bound(s => s.Clinician);
                        columns.Bound(s => s.SettingID).ClientTemplate(
                            "<a href='" + Url.Action("EquipmentSettingEdit", Controllers.Employee) + "/?equipmentid=#=item.ID#&settingid=#=SettingID#'" + "class='btn btn-sm'>Details</a>"
                            ).Width(75).Title("").Filterable(false);
                        columns.Template(
                            @<text>
                            <a href='@Url.Action("EquipmentSettingCopy", Controllers.Employee)' class='btn btn-sm'>Copy</a>
                            </text>).Width(75).Title("").Filterable(false);
                    })
                    .DataSource(dataSource =>dataSource.Server().PageSize(20))
                         
                    .Pageable(pageable => pageable
                        .PageSizes(true).PageSizes(new int[] { 20, 50, 100 })
                        .ButtonCount(5))
                    .Sortable()
                    .Filterable()
                    .Scrollable()
                )
            </text>
        )
        .RowAction(row =>
        {
            if (row.Index == 0)
            {
                //row.DetailRow.Expanded = true;
            }
            else
            {
                var requestKeys = Request.QueryString.Keys.Cast<string>();
                var expanded = requestKeys.Any(key => key.StartsWith("Settings_" +
                    row.DataItem.ID) ||
                    key.StartsWith("SettingItems_" + row.DataItem.ID));
                row.DetailRow.Expanded = expanded;
            }
        })
         
    )
 
</div>

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 03 Jul 2014, 03:32 PM
Hello Dan,

According to this post for server binding grids the URL should be created without using the #= # syntax

http://docs.telerik.com/kendo-ui/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/faq#how-do-i-use-action-links

Also for server bound Grids you should use Template not ClientTemplate.

Let us know your findings.

Kind Regards,
Petur Subev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Dan
Top achievements
Rank 2
Answers by
Petur Subev
Telerik team
Share this question
or