Add data attribute to Columns .HtmlAttributes

2 posts, 1 answers
  1. Tyler
    Tyler avatar
    64 posts
    Member since:
    Nov 2013

    Posted 02 Oct 2014 Link to this post

    I have a Kendo Grid as in code below - I have a View column which calls a javascript function.
    I want to add an action url to a custom data attribute i.e. data-actionurl on the column. In the javascript function I will then get the data attribute and redirect to that page.
    Is this possible?

        .Columns(columns =>
                columns.Command(command => command.Custom("View").Click("viewRevisedHouse")).Width("85px").HtmlAttributes( new {@data-actionurl=Url.Action('AjaxAdd', 'HouseFee', new {Oid = '#=Oid#'})});    //Error here
                columns.Command(command => command.Custom("View").Click("viewRevisedHouse")).Width("85px"); // This works fine
          columns.Bound(p => p.Oid).Visible(false);
          columns.Bound(p => p.ApplicationDate).Format("{0:dd/MMM/yyyy}").Title("Application Date");
          columns.Bound(p => p.RevisedHouseReason).Title("Revised Reason");
        .DataSource(dataSource => dataSource
            .Events(e => e.Error("handleAjaxError"))
            .Read(read => read.Action("RevisedHouses_GridRead", "House", new {originalHouseOid= Model.Entity.Oid }))

  2. Answer
    Petur Subev
    Petur Subev avatar
    1882 posts

    Posted 06 Oct 2014 Link to this post

    Hello Tyler,

    Adding URLs or calling custom JavaScript functions is always done by defining ClientTemplate for that column. You can find example in our FAQ section from the docs:

    Petur Subev

    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