th value change
th value change
Swetha9090
Posts: 28Questions: 5Answers: 0
in DataTables
Is there a way to change all header values or else can we append string to specified headers
Replies
You can use
columns.title
or you can use standard jQuery or Javascript methods to change the headers values.Kevin
Any examples
Is there any way to change the entire column with header and data to change its position
When you say change the entire column, header and data, do you mean something like ColReorder - please see example here.
If not, please can you explain more what you're trying to achieve, as you haven't given us enough information to help you,
Colin
I need example for appending text to some specified headers
If you just need to add text, you can either use
columns.title
as Kevin suggested, or just modify the element directly - please see example here,Colin
can i use targets:1,2,3,4 iin columndef
The
columnDefs.targets
docs provide all the options available to specify the columns. You can specify an array.Kevin
But How can I append string to column header
You can use my
initComplete
for that - see updated example here,Colin
For more than 2 columns how can i append?
Are you asking about
columnDefs
? If yes then see thecolumnDefs.targets
documentation to learn how to specify multiple columns. If this doesn't help then please provide more details of what you are wanting to do.Kevin
I want to append
_(underscore) to all the column headers....Is that is possible.If so can you provide with the example
You can use the jQuery .text() API for this. It is both a getter and a setter. I updated Colin's to show this for one column:
http://live.datatables.net/cabanege/7/edit
You can use jQuery each() if you want to loop through some or all the
th
elements.Kevin
Can you please provide example in which for all the columns we update _ at the starting position of header like _Name,_Age etc for all headers in the table
Here you go:
http://live.datatables.net/cabanege/13/edit
Kevin