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

Problem executing an action on custom command click

1 Answer 28 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michele
Top achievements
Rank 2
Michele asked on 25 Sep 2014, 10:29 AM
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

1 Answer, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 26 Sep 2014, 08:50 AM
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.

 
Tags
Grid
Asked by
Michele
Top achievements
Rank 2
Answers by
Dimiter Madjarov
Telerik team
Share this question
or