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

max lenght content in list view

1 Answer 212 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Manan
Top achievements
Rank 1
Manan asked on 26 Apr 2014, 10:00 AM
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.

1 Answer, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 29 Apr 2014, 12:01 PM
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!
 
Tags
ListView
Asked by
Manan
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Share this question
or