Updating a TD class on load -- Columns vary based on session variable
Updating a TD class on load -- Columns vary based on session variable
bpelon
Posts: 2Questions: 0Answers: 0
I'm pretty new to data tables so I apologize if I'm not finding something obvious.
I have a dataTables implementation that the amount of columns written to the table vary based on a php session variable used to toggle a minimized view and a full view. The data is loaded via ajax and the json sent back is adjusted server side.
I have all of that functioning, but I'm wondering how to add a class to certain fields knowing that I can't just predefine a call back like this example
[code]
"aoColumns": [
{"mData": "country", "fnCreatedCell": buttonCell},
{"mData": "operators", "fnCreatedCell": buttonCell},
{"mData": "platform", "fnCreatedCell": valueCell},
{"mData": "type", "fnCreatedCell": valueCell},
{"mData": "amount", "fnCreatedCell": createCell},
{"mData": "id", "fnCreatedCell": actionCell}
]
[/code]
--------------------
Sometimes I send back data for a structure with
ITEM 1ITEM 2
and other times the data structure is
ITEM 1ITEM 2ITEM 3ITEM 4
My current JS implementation is :
[code]
$('#ContactsTable').dataTable( {
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"sDom": '<"top"fpl>t<"F"pl>',
"bDestroy":true,
"oLanguage": {
"sLoadingRecords": " Loading Contacts Data"
},
"sAjaxSource": "PATH TO PHP FILE"
});
[/code]
I would prefer not to turn JS file into a php file if there is a way to handle this in data tables.
I have a dataTables implementation that the amount of columns written to the table vary based on a php session variable used to toggle a minimized view and a full view. The data is loaded via ajax and the json sent back is adjusted server side.
I have all of that functioning, but I'm wondering how to add a class to certain fields knowing that I can't just predefine a call back like this example
[code]
"aoColumns": [
{"mData": "country", "fnCreatedCell": buttonCell},
{"mData": "operators", "fnCreatedCell": buttonCell},
{"mData": "platform", "fnCreatedCell": valueCell},
{"mData": "type", "fnCreatedCell": valueCell},
{"mData": "amount", "fnCreatedCell": createCell},
{"mData": "id", "fnCreatedCell": actionCell}
]
[/code]
--------------------
Sometimes I send back data for a structure with
ITEM 1ITEM 2
and other times the data structure is
ITEM 1ITEM 2ITEM 3ITEM 4
My current JS implementation is :
[code]
$('#ContactsTable').dataTable( {
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"sDom": '<"top"fpl>t<"F"pl>',
"bDestroy":true,
"oLanguage": {
"sLoadingRecords": " Loading Contacts Data"
},
"sAjaxSource": "PATH TO PHP FILE"
});
[/code]
I would prefer not to turn JS file into a php file if there is a way to handle this in data tables.
This discussion has been closed.
Replies
two use cases for me were :
[code]
.dataTable tr td:last-of-type {
}
.dataTable tr td:not(:first-child) {
}
[/code]