Variable number of columns in dataTables. Number of cols decided dynamically

Variable number of columns in dataTables. Number of cols decided dynamically

imithyaimithya Posts: 5Questions: 0Answers: 0
edited September 2010 in General
Hi Allan,

I have been trying to use dataTables on my page which has multiple tables each having different number of columns. The number of columns for each of the tab le is decided dynamically when the data from the server is being filled in the table.

I am using mason in which I iterate over the array containing data and fill the html table.

With same constructs if I use fixed number of columns then the dataTable works properly.

Can you suggest something to work around this? I am using dataTables 1.7.2.

Thanks
Pooja Gupta

Replies

  • imithyaimithya Posts: 5Questions: 0Answers: 0
    Hi

    Is it possible to initialise each table on the webpage separately with datatables?

    Regards
    Pooja Gupta
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi Pooja,

    Unfortunately I introduced a bug in 1.7.2 which is causing a few issues when initialising multiple tables in a single call with different column lengths. This has been fixed in the development version which can be downloaded from here: http://github.com/DataTables/DataTables/blob/master/media/js/jquery.dataTables.js . That will form part of the 1.7.3 release. Let me know if you have any problems with it.

    Allan
  • imithyaimithya Posts: 5Questions: 0Answers: 0
    Hi Allan,

    1.7.3 is the dev version and I have to put my code in production.

    What about 1.7.1, does it also have similar problems? In another thread you said that you introduced the bug by mistake in 1.7.2, so 1.7.1 should do well.

    Thanks
    Pooja Gupta
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Yes 1.7.1 will not show this problem, so you could rollback to that as well. Basically the reason for it was that I was inadvertently manipulating the object which was passed into DataTables to count the number of columns - this meant that when it came to process the second table, there was now a column array, and that didn't match the second table's columns :-(

    There are only two changes between 1.7.2 and the currently committed development version, the first to fix the problem you are seeing, and the second to fix an issue with TableTools 2 (as yet unreleased, so it's unlikely to effect anyone) when infinite scrolling and using server-side processing.

    It might be worth looking over the 1.7.2 release notes ( http://datatables.net/download ) before rolling back to 1.7.1 to see if there is anything that might effect you (most of the fixes were edge cases though).

    Regards,
    Allan
This discussion has been closed.