max lenght content in list view

2 posts, 0 answers
  1. Manan
    Manan avatar
    5 posts
    Member since:
    Apr 2014

    Posted 26 Apr 2014 Link to this post

    Hi I am using kendo listview component as seen below:


    $("#showHide").kendoListView({dataSource: vals,template: "<div style='overflow: hidden;text-overflow: ellipsis;white-space: nowrap;margin:4px;'>#:name#</div>",selectable: "multiple",
    change:  function() {
    selected = $.map(this.select(), function(item) {
    return vals[$(item).index()].name;
                  });     
    },
    });

    Is there any way that i can find the max lenght element of whole content. for example 
    1). asdf
    2).asdfsadfasdf
    3).asdfasdfsadfsadfasdf

    In this 3 element is largest.

    Please suggest if there is any way we can find the max length of all the elements.
  2. Alexander Popov
    Admin
    Alexander Popov avatar
    1416 posts

    Posted 29 Apr 2014 Link to this post

    Hello Manan,

    Although this is not supported out of the box, it could be achieved by subscribing to the ListView's dataBound event. Once the event is triggered you could iterate over the currently displayed items through the DataSource's view method and check their length. For example: 
    <script>
        function onDataBound() {
            var items = this.dataSource.view();
            for (var i = 0; i < items.length; i++) {
                ...
            }
        }
    </script>


    Regards,
    Alexander Popov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
Back to Top