Add class to cell when using server-side processing
Add class to cell when using server-side processing
![Tklaversma](https://secure.gravatar.com/avatar/93cfceee52f94b05ba04bf646ff7ece4/?default=https%3A%2F%2Fvanillicon.com%2F93cfceee52f94b05ba04bf646ff7ece4_200.png&rating=g&size=120)
Reopening #13619
Question: How to add classes to cells when using server-side processing?
Allan said in January 2013 it is not possible to add a class to individual cells using built in options. But I'm curious if it's possible now?
If still not, can you guys give me a code example of how to do this?
TK
= = = = = = =
Answer to workaround, add:
createdRow: function(row, data, index) {
$('td', row).eq(6).addClass('whatever'); // 6 is index of column
},
This discussion has been closed.
Replies
For example:
other way:
But first way is simpler
I think you misinterpreted my question. Let me rephrase by using my actual problem and data. Here goes:
I load data in to the table using server-side processing. Their is a column thats shows dates in the Dutch way (dd-mm-yyyy). So visually you'll see a dutch date, but when sorting you want to sort on 'yyyymmdd'....so we need to add a data-order attribute to the cell. The thing is, like describe here, you cannot use data-order attributes when dealing with dynamic data, unless you do something like this:
So I did use this. Next problem....since the data is loaded into the cells after the rows are created AND data-order attributes are added (they will be empty), this solution does not work.
So my actual question is, how to show a Dutch date and still sort on 'yyyymmdd' when using server-side processing?
My first solution was to load the English date into the table and afterwards (createdCell callback) change the date to Dutch style.
The problem with this is that when an user searches on for example 12-12-2012, no records will be shown since the actual date in the cell is 2012-12-12.
So how to get this last part fixed?
What is your data source?
I'm still curious to the answer, but I fixed it in Php.
When user requests a sort
$_POST['order'][0]['column']
, check if the request is for the date column.If so, sort them on the yyyy-mm-dd way...
I went a little off topic here by posting a Php-solution, but than again, this works..