Correct way to use html-attributes taghelper

2 posts, 0 answers
  1. Marcel
    Marcel avatar
    42 posts
    Member since:
    Apr 2011

    Posted 08 Mar 2018 Link to this post

    I was struggling with the kendo-toolbar taghelper to add an html attribute to a toolbar item, but eventually figured it out.
    Is this the correct way to use the html-attributes taghelper or is there a shortcut ?

    <item type="CommandType.Button" text="Delete" html-attributes='new Dictionary<string, object>{ ["class"] = "float-right" }' />

    Thanks in advance

  2. Dimitar
    Dimitar avatar
    729 posts

    Posted 13 Mar 2018 Link to this post

    Hello Marcel,

    In general, the Toolbar does not work with HTML elements, but rather dynamically generates its content. Therefore, adding a class="col-sm" will not add the desired class to the Toolbar item. Instead, by using the html-attributes, the "float-right" class will be correctly set to the element, as the data is being serialized correctly.

    Currently, there is no shortcut available and the attributes can be added with the specified signature:
    html-attributes='new Dictionary<string, object>{ ["class"] = "float-right" }'

    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top