createdRow for Visible Columns
createdRow for Visible Columns
Hello,
I have a multi-tabbed DataTable and each different tabbed table represents a different Department. Through my REST I am calling 12-15 fields but only showing 8 different values.
Those are User/Name, Locations (a calculated field showing, MondayLocation, TuesdayLocation, WednesdayLocation, ThursdayLocation, & FridayLocation), Sunday, Monday, Tuesday,Wednesday,Thursday,Friday. The other values being pulled through the REST are MondayStatus, TuesdayStatus, WednesdayStatus, ThursdayStatus, FridayStatus.
I know I have to populate these to the table but give them no visibility for this to work. But if they are hidden can I still call the createdRow function to give the row a certain color based on the values in those fields. I.E (if all 5 status fields = P(present)) then display the row as green. Etc.
This question has an accepted answers - jump to answer
Answers
Use the
data
parameter of thecreatedRow
callback to access the data for the row.Kevin
@kthorngren
As you can see I implemented the "createdRow" callback within my table declaration, in my VSCode it tells me that @
"columns": [
;
is expected, and at"order":
a;
is expected. After closing the table});
it tells me a,
is expected? Am I implementing this right?It works fine in this example http://live.datatables.net/tohehohe/6725/edit
And I just realized what I titled this discussion... I meant for hidden columns.
I figured
You need to add a comma to separate the options on line 7 after the
}
. You are using object data so instead ofdata[9]
you need to usedata.MondayStatus
or whatever the appropriate data point is.Kevin
I inserted a comma after the option like the following, and it is still telling me the same issue.
With the comma, in console it tells me
unexpected token ','
and without the comma it tells meunexpected token ':'
@"columns": [
UPDATE: I was missing a bracket after line 7, it works perfectly now. But one question I still have related to this is can I have it highlight everything in the row but the User.Title field?
You can use the jQuery :not() selector. Maybe something like
$('td:not(:first-child)', row).addClass('red');
.Kevin