Addingattributes to LI when using templating

4 posts, 0 answers
  1. Bart
    Bart avatar
    11 posts
    Member since:
    Jul 2013

    Posted 25 Jul 2013 Link to this post

    http://docs.kendoui.com/api/mobile/listview#configuration-template

    I am using templates, as described in the above link. In the docs is says, "The ListView automatically wraps the template content in <li> tag. Putting a <li> tag inside the template creates invalid nesting of elements."

    So how do I add a class or another attribute to the LI item?
  2. Bart
    Bart avatar
    11 posts
    Member since:
    Jul 2013

    Posted 25 Jul 2013 Link to this post

    One way I just figured out is this, though there may be a better way to go about this?

    onDataBound: function(event){
      event.sender.element.children().each(function(index, li) {
        $(li).addClass('status-warning');
      });
    }
  3. Kendo UI is VS 2017 Ready
  4. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2566 posts

    Posted 26 Jul 2013 Link to this post

    Hi Bart,

    I examined other options to achieve the effect you are looking for, but did not manage to find a better solution than the one that you already have. As the widget itself does not apply any styling to the <li> elements, there is no class attribute that can be used to style the elements, so you need to add one - as you do in your script binded to the DataBound event.
     
    Regards,
    Kiril Nikolov
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  5. Bart
    Bart avatar
    11 posts
    Member since:
    Jul 2013

    Posted 26 Jul 2013 Link to this post

    Thanks for looking into it, Kiril.
Back to Top
Kendo UI is VS 2017 Ready