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

Listbox - Alternate Row Colors

1 Answer 309 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Jeffrey
Top achievements
Rank 1
Veteran
Iron
Iron
Jeffrey asked on 14 May 2020, 03:25 PM

Hello

Is there a way to have the listbox alternate row colors?  An type of slight row shading would work. 

 

Thank you

Jeff

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 18 May 2020, 08:36 AM

Hello Jeffrey,

Alternating rows in the ListBox is not a built-in functionality, however, it can be easily achieved. The ListBox renders as an unordered list, thus the items list can be traversed and a custom CSS class appended applying the desired color. For example:

$('ul li').each(function(index, element) {
    if( index % 2) {
        var li = $(element).addClass("alternatingColor");
     }
});
...
<style>
      .alternatingColor {
        background-color: aliceblue;
      }
 </style>

This can be examined live in the following Dojo demo:

Let me know if you have any questions.

Regards,


Nikolay
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
ListBox
Asked by
Jeffrey
Top achievements
Rank 1
Veteran
Iron
Iron
Answers by
Nikolay
Telerik team
Share this question
or