Row colour

Row colour

PetrSPetrS Posts: 3Questions: 0Answers: 0
edited June 2013 in General
Hi all,
I am quite new to DataTables but it seems to me very useful. I would like to ask you something regarding row colouring.
I have a database of 2000 records - sales orders, each has several items. I need to color each sales order by specific color.
e.g. sales order number 100 with all the items will be coloured in blue etc.
Already I have a hex code in my database. Here is a short example of my db. So first row should be in colour #FFEFDB
and second/third lines should be in #FF4040

order control colour
4 M02 #FFEFDB
333 M02 #FF4040
333 M02 #FF4040

Is there any chance to do this using some function ? If yes, where to put the code.
Thank you for any advice
Petr

Replies

  • aaronwaaronw Posts: 89Questions: 3Answers: 4
    You can do this a variety of ways. In my case, what I chose to do is to mark a DT_RowClass on specific rows that are returned from the server - http://www.datatables.net/release-datatables/examples/server_side/ids.html You don't need to do server-side processing to return that array value. Then, in the CSS on the page I look for that particular class and then set the background-color to a certain color, and that's done.

    Or, you could use mRender to look for specific items in cells and then rewrite the HTML for that row.

    Or, you could hook into fnCreatedRow to either add a CSS class or a HTML background-color at that time. There are a variety of appraoches.
  • PetrSPetrS Posts: 3Questions: 0Answers: 0
    Thanks for your help. Its working fine.
This discussion has been closed.