aoColumnDefs with colspan in header?

aoColumnDefs with colspan in header?

FabianFabian Posts: 1Questions: 0Answers: 0
edited October 2011 in General
Hello everyone,
first of all - DataTables is such a great tool! we planned to start using jQuery for a longer time but I never had the time to look deeper into it, now we have been really in need for a plugin like DataTables and it was so easy to install and does have awesome functions that would have taken me weeks to programm on the server-side.

But I have one little question/problem where I am not able to sort it out with the documentation/forum posts:
Is there any way to use colspan with aoColumnDefs? I have three columns in the table where I only want to have one heading but the table itself should have all the three. Sounds simple ... and I hope it is!

Best regards and thanks for your help
Fabian

Replies

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Good to hear you like to the look of DataTables :-)

    > Is there any way to use colspan with aoColumnDefs? I have three columns in the table where I only want to have one heading but the table itself should have all the three

    DataTables requires that each column in the table's body has a cell in the header which is unique to that column (for sorting, column detection, show/hide etc). So it's not possible to have a colspan of three in the header without having a second row which would have the individual cells.

    The way around that is to put the second row into your THEAD as required by DataTables, but then after the initialisation has been completed, just use removeChild() to pull the row you don't want out of the DOM.

    Allan
This discussion has been closed.