problem with state save on datatable server side and custom filters with yajra datatables

problem with state save on datatable server side and custom filters with yajra datatables

theodoropoceid@gmail.comtheodoropoceid@gmail.com Posts: 1Questions: 1Answers: 0
edited March 2020 in Free community support
function fill_datatable(filter_programma,filter_prosklhsh,filter_foreas,filter_katastash)
    {
    var datatable=$('#table_protaseis').DataTable({
        "language": {
            "processing": "Αναζήτηση ...",
                     "emptyTable": "Δεν υπάρχουν δεδομένα στο πίνακα",
                     "paginate": {
                         "next":       "Εμενο",
                         "previous":   "Προηγούμενο",
                     },
                 },
        // "searching": false , 
        // "bInfo" : false,
        // "bLengthChange": false,
        processing: true,
        serverSide: true,
        ajax: {
          url : '/list',
          data: {filter_programma:filter_programma,filter_prosklhsh:filter_prosklhsh,filter_foreas:filter_foreas,filter_katastash:filter_katastash},
          type: 'GET',
        },
        columns: [
            { data: 'kodikos', name: 'kodikos', className: "text-center" },
            { data: 'prosklhsh.syntomeysh', name: 'prosklhsh.syntomeysh', className: "text-center" },
            { data: 'foreas_ylopoihshs.name', name: 'foreas_ylopoihshs.name' },
            { data: 'titlos_protashs', name: 'titlos_protashs' },
            { data: 'hm_prot_forea', name: 'hm_prot_forea', className: "text-center" },
            { data: 'proteinomenos_proypologismos', name: 'proteinomenos_proypologismos', className: "text-right" },
            { data: 'status', name: 'status', className: "text-center" },
            { data: 'apofaseis_hm_prot', name: 'apofaseis_hm_prot', className: "text-center" },
            { data: 'apofaseis_synoliko_poso', name: 'apofaseis_synoliko_poso', className: "text-right" },
            { data: 'action', name: 'action', orderable: false},
        ],
        // "stateSave": true,
        // "bStateSave": true,
        // "fnStateSave": function (oSettings, oData) {
        //     localStorage.setItem( 'table_protaseis', JSON.stringify(oData) );
        //     },
        // "fnStateLoad": function (oSettings) {
        //     return JSON.parse( localStorage.getItem('table_protaseis') );
        //     },
          
     });
    }
    fill_datatable();

this is my code and i make use of localstorage through fnStatesave but i dont understand what i have to do in order to keep the state of datatable json and reload on refresh!thanks in advance

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    stateSave by default will keep track of paging, searching and ordering. Can you give more details on what you're trying to achieve, please.

    Colin

This discussion has been closed.