Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
165
rated 0 times [  172] [ 7]  / answers: 1 / hits: 32297  / 12 Years ago, wed, january 9, 2013, 12:00:00

I made a large table for jquery.datatables which is works great for me.

but i need a class name set to each td element relative to its column.

fo example i want a column (including th and all td's) have a class=volume.

there is this issues:

i use this code to initialize the class but it is not working.



aoColumnsDefs: [
{ sClass: volume, aTargets: [2] }
]


EDIT:
my table is created and refeshes dynamically. and it is made of a js-array which i prefer not to touch it ie. just to add class names

EDIT:

iuse this code to itialize my table:



$('#dataTable').dataTable({
aaData: dataCnt,
aoColumnsDefs: [
{ sClass: volume, aTargets: [2] }
],
aoColumns: columnsHd,
bStateSave: true,//saving status in coockie
iCookieDuration: 10,//coockie life duration in seconds
sScrollX: 100%,
sScrollY: (winHei-200),
sDom: '<HRCfrl>t<pFi>',
oColVis: {
buttonText: &nbsp;,
bRestore: true,
sAlign: left
},
aLengthMenu: [[10, 25, 50, -1], [10, 25, 50, All]]
});


i hope it helps
*EIDT: *

columnsHd is an array which is created dynamicaly from my json headers and now is exactly:



[
{ sTitle: macaddr },
{ sTitle: lat },
{ sTitle: ip },
{ sTitle: clientname },
{ sTitle: relay0mask },
{ sTitle: relay0stat },
{ sTitle: relay1stat },
{ sTitle: clientid },
{ sTitle: bldname },
{ sTitle: uptime },
{ sTitle: current },
{ sTitle: temperature },
{ sTitle: softver },
{ sTitle: volume },
{ sTitle: hardver },
{ sTitle: relay1mask },
{ sTitle: pic },
{ sTitle: comment },
{ sTitle: lon },
{ sTitle: rtt },
{ sTitle: bldaddr },
]

More From » jquery

 Answers
24

My guess is that aoColumns: columnsHd, overrides the aoColumnsDefs: [ { sClass: volume, aTargets: [2] } , ],



Try to replace their order in code



Or just add the class directly in aoColumns: columnsHd,
like this sClass: volume



complete code :



try changing { sTitle: ip }, into { sTitle: ip, sClass: volume },



and remove the



aoColumnsDefs: [
{ sClass: volume, aTargets: [2] }
],





Note that in datatables 1.10 you should use aoColumnDefs


[#80986] Tuesday, January 8, 2013, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
carlymykalac

Total Points: 740
Total Questions: 91
Total Answers: 91

Location: Sudan
Member since Thu, May 7, 2020
4 Years ago
carlymykalac questions
Fri, Dec 10, 21, 00:00, 3 Years ago
Mon, Sep 2, 19, 00:00, 5 Years ago
;