looking for some solutions? You are welcome.

SOLVED: Datatable stateLoadCallback Condition

0x00b0:

I have a Datatable which using stateLoad

Here is my js code :

table = $('#sparepart_id').DataTable({
         "paging": false,
         "stateSave": true,
         // "pagingType": "full_numbers",
         "lengthChange": true,
         "searching": false,
         "ordering": true,
         "info": false,
         "autoWidth": false,
         "pageLength": 25,
         scrollX: true,
         stateLoadCallback: function(settings, callback) {
            var o;
            $.ajax({
               url: BASE_URL + "spareparts/load_layout",
               type: "POST",
               data: {
                  user_id: user_id
               },
               async: false,
               dataType: 'json',
               success: function(json) {
                  o = JSON.parse(json.json);
               },
               error: function(data) {
                  console.log(data);
               }
            });
            return o;
         }
    });

Here I want do if else statement , if json empty do not load state , but if json isn't empty do load state

Anyone can help me out ?



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
Share:

No comments:

Recent