Is it possible to save the selected number of records in a datable so that when you log in again it is the same?

0

As the question says, I'm looking for some way to save the selected records of a databtable, something like staying logged in from facebook.

I explain myself in a better way: if I see the records of a table, initially I show 10, I mark the option and then I select that I want to see 100 records.

Is it possible that when you update the page, the 100 records that you select, will reappear?.

I remain attentive to your comments.

    
asked by Juan Mellado J. 14.06.2018 в 07:13
source

2 answers

0
$('#example').DataTable( {
        stateSave: true
    } );
    
answered by 18.06.2018 / 12:21
source
1

DataTables has the option to save the state of a table (its paging position, ordering status, etc.) so that it can be restored when the user reloads a page, or returns to the page after visiting a subpage. This state-saving capability is enabled by the stateSave option.

The built-in state-saving method uses HTML5's localStorage and sessionStorage APIs for efficient data storage. Note that this means that the built-in state-saving option will not work with IE6 / 7 since these browsers do not support these APIs. Alternative options to use cookies or save the status on the server through Ajax can be used through the options stateSaveCallback and stateLoadCallback.

The duration for which the saved state is valid and can be used to restore the state of the table can be set using the stateDuration initialization parameter (2 hours by default). This parameter also controls whether localStorage (0 or greater) or sessionStorage (-1) is used to store the data.

The following example simply shows the state savings enabled in DataTables with the stateSave option.

   $(document).ready(function() {
    $('#example').DataTable( {
        stateSave: true
    } );
} );
    
answered by 18.06.2018 в 10:36