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

Add a css class to the ListView's container?

1 Answer 271 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Kurt
Top achievements
Rank 1
Kurt asked on 12 Oct 2012, 07:38 PM
Is there any way to add a CSS class to a ListView's container?

For example, I would like to add the CSS class "row" so it looks like this:
<div id="CertificationList" class="row k-widget k-listview" data-role="listview">

This is the ListView:
@(Html.Kendo().ListView(Model)
    .Name("CertificationList")

1 Answer, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 15 Oct 2012, 06:57 AM
Hello Kurt,

With Q2 2012 SP1 HtmlAttributes was introduced to ListView MVC wrapper. You can use it to add various attributes(including class names) to ListView wrapper element.

All the best,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Michael
Top achievements
Rank 1
commented on 13 Sep 2021, 03:01 PM

I realize this is very old and not sure if I'l get a response, but I am encountering an issue here.

 

I am trying to apply a flexbox container class, and using HTMLAttributes puts it on the external k-listview container, not k-listview-content, and thus it does not apply.  Is there a way to apply a class to the content div?

Anton Mironov
Telerik team
commented on 16 Sep 2021, 10:11 AM

Hi Michael,

In order to achieve the desired behavior, I would recommend using the jQuery selector for getting the needed container. Using the "addClass" method will provide the opportunity to set the required class and apply the styles as per the needs of your application. Here is an example:

Give a try to the approach above and let me know if further assistance is needed.

Kind Regards,
Anton Mironov

Tags
ListView
Asked by
Kurt
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Share this question
or