Using filtering API on a hidden datatable.. possible?

Using filtering API on a hidden datatable.. possible?

replicantreplicant Posts: 2Questions: 0Answers: 0
edited December 2012 in DataTables 1.9
I have a unique usage (at least as far as I can tell based on the lack of other folks doing something similar) of datatables to where I'm using datatables for its filtering/sorting/paging functionality, but retrieving the data and running the returned table row data into a mustache template to create a non-tabular layout of the data (basically turning the tabular data/layout into a nicely formatted list from that datatable data using fnGetData and fnGetFilteredData plugin that Allan created a while back). So in order to do this, I have a datatable on the page as well as my mustache template (using ICanHaz.js for doing this). Everything works great.. until I HIDE the container that holds the datatable.. Is it possible to interact with a datatable even when it is hidden with a simple display:none on the table element (or even on some outer parent container to the main datatable table element)?

Thanks for your help. If code samples would help, please let me know what I'd need to post.

-replicant

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Yes, it should work in exactly the same way as if it were visible. Obviously if you use any calculations that require visibility then there will be an issue (column width is the most common one), but display:block or display:none - it should make no difference to the DataTable.

    If you could link to a test page, with instructions on how to reproduce the issue, that would be useful.

    Allan
  • replicantreplicant Posts: 2Questions: 0Answers: 0
    Allan, I ended up just positioning the datatable WAY out of the viewport. I'm going to revisit this as part of the infinite amount of technical debt that we accumulate through projects. :D

    Will post up a gist or jsfiddle with errors, sample markup and js to replicate the issue.

    In the meantime, here is the error I was receiving when the container that holds the table that is referenced to instantiate the datatable:
    Uncaught TypeError: Cannot read property 'oFeatures' of null

    It throws that when i call fnFilter on aforementioned datatable.

    Like I said, I'll come back to this to discuss a real solution for this (not just hiding it via absolute positioning).

    Thanks for your time Allan, you're posts and plugins have been most helpful here.
This discussion has been closed.