clarification of column mapping for complex headers

clarification of column mapping for complex headers

juliangrahamjuliangraham Posts: 3Questions: 0Answers: 0
edited September 2010 in General
Hi all,

We're trying DataTables to create a table with "complex headers" (as described here: http://datatables.net/examples/advanced_init/complex_header.html), but we're also doing server-side processing and doing some additional column-level initialization via the "aoColumnDefs" property, and I'm having a hard time understanding the following:

* How does DataTables treat the "column group" headers -- i.e., the first in a multi-row -- in the context of calculating the number of "required" columns in a row of data returned from the server? Do we need to pad our data with nulls for these headers?

* How are the column indexes that are sent to the server for the purposes of sorting calculated when there are column group headers? It seems like the sort column indexes are different when there are column group headers (but I'd have to check again).

* Is there a way to have DataTables create column group headers via some settings in aoColumnDefs as opposed to determining them from the structure of the target DOM element?


Thanks!

Replies

  • allanallan Posts: 63,205Questions: 1Answers: 10,415 Site admin
    Hi juliangraham,

    1. Basically what happens is each column in the table must have a unique TH element to itself (i.e no colspan, making it go over multiple columns). It's possible to have more than one TH element dedicated to each column, that's fine - but there must be at least one. The way DataTables works is it will look at the DOM and determine the list of unique TH elements to calculate the columns from. This number dictates how many elements much be in the array returned from the server.

    2. The column indexes will match whatever the list of unique TH elements is. Everything revolves around that for the column detection (_fnGetUniqueThs is the function in question).

    3. No - DataTables will only create single cell elements when needed at the moment. What you can do however, is simply construct the DOM you want using standard DOM/Javascript / jQuery methods, if you don't want it in the HTML.

    Regards,
    Allan
This discussion has been closed.