Problem executing an action on custom command click

2 posts, 0 answers
  1. Michele
    Michele avatar
    426 posts
    Member since:
    Jun 2009

    Posted 25 Sep 2014 Link to this post

    Hello,
    I've a grid defined as 
    @(Html.Kendo().Grid<Communications.Communication>()
            .Name("grid")
            .Columns(columns =>
            {
                columns.Bound(c => c.Protocol).Title(ResourceStrings.Protocol);
                columns.Bound(c => c.Date).ClientTemplate(@DateTimeHtmlHelper.GetParsedDate("Date")).Title(ResourceStrings.Date);
                columns.Bound(c => c.CodiceRapporto).Title(ResourceStrings.CodeDossier);
                columns.Bound(c => c.Type).Title(ResourceStrings.Type);
                columns.Command(commadnAction => commadnAction.Custom("download").Text("Download").Click("Download"));
            })
            .Resizable(resize => resize.Columns(true))
            .Scrollable(scr => scr.Enabled(true))
            .Filterable()
            .Sortable()
             .DataSource(dataSource => dataSource
            .Ajax()
            )
            .ToolBar(toolbar =>
            {
                toolbar.Template(@<text>
                    <div class="toolbar">
                        <label>Data da </label>
                        @Html.Kendo().DatePicker().Name("dateFrom").Value(@Model.DateFrom)
                        <label> Data a </label>
                        @Html.Kendo().DatePicker().Name("dateTo").Value(@Model.DateTo)
                        @Html.Kendo().Button().Name("btnCarica").Content(ResourceStrings.BtnLoadData).Events(events => { events.Click("LoadData"); })
                    </div>
                </text>);
            }
            )
    )

    <script>
        function Download(e) {
            var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
     
        var content ="@Html.ActionLink("CommunicationsReport", "Reports", new { protocol = 123 })"
     
            alert(content);
     
        }
     
    </script>

    I wish at column click to load open a new page for downloading a pdf....

    in other parts of the project I've used something as

    var content ="@Html.ActionLink("CommunicationsReport", "Reports", new { protocol = 123 })"

    but now I can't since I don't have the link client side.... is there any simple way of doing that?

    Thanks
  2. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2310 posts

    Posted 26 Sep 2014 Link to this post

    Hi Paolo,


    A sample approach would be to use window.location.href to navigate to the new page.
    E.g.
    window.location.href = "/Reports/" + dataItem.protocol;

    Regards,
    Dimiter Madjarov
    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.

     
Back to Top