Click here to Skip to main content
15,749,072 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am using 

Rows in tables are arranged with EmployeeGroupNumber. 

I would like to have even EmployeeGroupNumber rows with one color and odd with another. so that it could be clean to separate the details in the table

What I have tried:

currently I am using bootstrap
class which makes alternate rows with separate color which I do not want.
Updated 17-Mar-18 3:56am
F-ES Sitecore 16-Mar-18 10:52am    
Change the table-striped class to use the styles you want, or create a new class with the styles you want and use that class instead.
A_Griffin 16-Mar-18 13:48pm    
What's the difference between "alternate rows with separate color" and having even numbered rows with one color and odd numbered rows with another?
istudent 16-Mar-18 15:01pm    
my rows will be sorted by column 'Group number'. so I want rows with group Number '1' red. and group Number '2' green.


1 solution

You will need to provide the implementation for createdRow event that would be called for each row and there you can change style of the row on some business logic like following:

"createdRow": function (row, data, index) {
                            if (data["Building"] == null)
                            switch (data["Building"].toLowerCase()) {
                                case 'west':
                                    $('td:not(:last-child)', row).css({
                                        'background': 'red',
                                        'color': 'white'

What i was doing here is set the row background-color to read and text-color for all the row cells white.

Hope it helps.
Share this answer
istudent 18-Mar-18 23:18pm    
Thank you. I think it will work. I will try this tomorrow. I have another question. When i passed token, I got error. Do you know something about it? I will appreciate
Ehsan Sajjad 19-Mar-18 13:18pm    
No, i am not getting what you are trying to ask, you can post a new thread about that

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900