0
votes

I am using Yajra datatable for laravel from this link. My requirement to save state of datatable.

In this datatable "Html Builder Event Callbacks" are present in this link.

But example for how to use "stateSaveCallback" not present. Is any one know how to use this callback for save table state?

2

2 Answers

0
votes

I haven't tried yet before. But, when I look around their documentation, here some possibility. I just reference from https://datatables.net/reference/option/stateSaveCallback and https://github.com/yajra/laravel-datatables

$builder->parameters([
    'stateSave'=>true,
    'stateSaveCallback' => 'function(settings,data){ //do your code}',
]); 
0
votes

You can try below example code with api 'backapi/save_state' to store state call back

$('#my-datatable').DataTable({
    "stateSave": true,
    "stateSaveCallback": function (settings, data) {
        //Custom AJAX to store state
        $.ajax({
            "url": "/api/save_state",
            "data": data,
            "dataType": "json",
            "success": function (response) {}
        });
    },
});