Buttons text from Column Title
Buttons text from Column Title
ThomD
Posts: 334Questions: 11Answers: 43
I noticed that when using Buttons with the ColVis module (the new one, not the stand alone), the buttons get their names from the TH element, not the Title of the column as defined in the columns setup. So, rather than having "Title", "Name", Salary", I get
"Column 1", "Column 2"....
Is there a way to get Buttons to pick up the Titles?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
The answer is to use the new $.fn.dataTable.Buttons() constructor technique, rather than initiate the Buttons as part of the table definition setup. This makes sense because when the Buttons are created during that process, the column headers have not been converted to the Column Titles.
Using the example here works
http://datatables.net/extensions/buttons/examples/initialisation/new.html
note that you cannot include the 'B' parameter in the dom configuration because when that code runs, there are no Buttons to insert.
Hi,
Thanks for raising this. I've just committed a change for Buttons to use the TableTools behaviour and read from DataTables' internal data store rather than the DOM. There was another thread which noted that you can't use
columns.title
with Buttons (which I now can't find...), which also requires this change.I think longer term DataTables need to add a
column().title()
get / set API for this, but in the short term, this is possibly the best option.It will be included in Buttons 1.0.1 which I'm going to release on Friday.
Allan