Ajax + initializing with class fails to maintain state (bug?)
Ajax + initializing with class fails to maintain state (bug?)
Hey, I created a test page just for this: http://nettitaivas.com/dev/datatables/index.html
It should be pretty self explaining.
Ps. Great thanks for the developers for this great software.
Here is the description for archiving purposes as well:
Ajax colvis/state loading problem
Description
This example uses Ajax to load table to DOM, you can reload the table by hitting Load Table-link. And after that it will load datatable.html to div below.
Problem is that displayed columns aren't preserved correctly after Ajax-calls / new DataTables creation even if stateSave is true. You can see this as the columns keep changing between "Load table" button hits. With hitting browser full page refresh data is loaded correctly from the state and correct columns are shown.
Problem is related to initializing with class-selector
This seems to be related to table beign initialized with class: <table class="tablesorter">
and $('.tablesorter').DataTable(options);
If I change the class to id: <table id="tablesorter">
... and $('#tablesorter').DataTable(options);
the problem seems to be fixed.
Expected / current behaviour
Prerequisites: Hide column "Surname", refresh page. Hide column "First name", refresh page. Hide column "ID", refresh page. Now start hitting link "Load table", may take 10+ clicks before strange behaviour procs.
Expected result: Selected columns are preserved between ajax-calls when hitting "Load table"-link.
Current result: Columns aren't preserved, infact they are changed constantly when hitting "Load page"-link.