Headers showing twice when using javascript array as a source

Headers showing twice when using javascript array as a source

juan pablojuan pablo Posts: 2Questions: 0Answers: 0
edited January 2011 in Bug reports
Hi... this is my first post on this list... so i hope i can be descriptive enough.
I'm using datatables to generate some tables reports in HTML.
To feed the tables, i'm using a javascript array as a source ( "aaData": [["0","FIRST",],["1","SECOND",], and so long ...] ).
The problem arises when i try to save the page to a file. All the table headers and footers are shown twice (the search header,the amount of rows, the amount of records shown footer and the prev and next buttons) . Yes, i'm using search and paging.
I went directly to the html source and looked that the info for the table is being shown twice :

[code]


Show 15All entriesSearch: Processing...ClientUsername0FIRST1SECOND...Showing 1 to 15 of 2,334 entries

$(document).ready(function() { $('#table-1').dataTable({....});

[/code]

So... my guess is that when you load the table from a javascript array and save the html page, the headers and footers are shown twice because in the source there is the table data, ( look all the divs listed previously in the code, they have been added by the library) and there is also the tag, containig all the table information again. So...there might be a bug because the headers and footers are being shown twice.

I hope all the information is clear enough. Great work!

Replies

  • juan pablojuan pablo Posts: 2Questions: 0Answers: 0
    Now i'm not so sure if it is a bug, perhaps allan could figure that out. The problem is that whenever i wanted to save the contents of a html page to a file, the duplicated headers and footers were there. I found a workarround to the problem and it basically is to add a "refresh" of the main table div in the script:
    [code]

    $(document).ready(function() {
    $('#tableDiv-1').html( ' ' );
    $('#table-1').dataTable({
    "bPaginate": true,
    "bLengthChange": true,
    ...
    ...
    [/code]

    I have another question =) :

    Is it possible to save the state in a "hidden field" or in the dom, instead of a cookie?... Because i need to be able to save the html page in a file and then, when the file is opened again, i need the state to be reloaded ( page size, page, etc).
    Do i have to hack the _fnCreateCookie and _fnReadCookie to make them save into the DOM instead of a cookie?
This discussion has been closed.