multi_select_custom_func filter_type stateSave and stateLoad

multi_select_custom_func filter_type stateSave and stateLoad

ZsoZZsoZ Posts: 1Questions: 1Answers: 0

Hi!

I a have table with some filter. One of the filter is a "multi_select_custom_func" filter.
I can save and load every filter state except the one with "multi_select_custom_func".
How can i save and load the "multi_select_custom_func" filter state?
Thanks.

Here is my code:

            var antennaTable = $('#antennaListTable').DataTable({

                fixedHeader: true,
                "autoWidth": true,
                "lengthMenu": [[5, 10, 25, 50, -1], [5, 10, 25, 50, "Osszes"]],

                "columnDefs": [
                { "orderable": false, "targets": 0 }
                ],
               
                colReorder: {
                    fixedColumnsLeft: 1
                },

                dom: 'Blfrtip',
                buttons: [
                { extend: 'colvis', text: 'Oszlopok láthatósága' }
                ],

                "stateSave": true,
                "stateSaveParams": function (settings, data) {
                    data.userid = $('#userId').val();
                },

                "stateSaveCallback": function (settings, antennatablestate) {
                    
                    $.ajax({
                        "type": "POST",
                        "url": "AntennaList.aspx/state_save",
                        "data": JSON.stringify({ 'antennatablestate': antennatablestate }),
                        "contentType": "application/json; charset=utf-8",
                        "dataType": "json",
                        "success": function () { }
                    });
                },

                "stateLoadCallback": function (settings, callback) {


                    $.ajax({
                        type: "POST",
                        url: "AntennaList.aspx/state_load",
                        data: "{'userId':" + $('#userId').val() + "}",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (response) {
                            var jsonData = JSON.stringify(response.d);
                            callback(response.d);
                        },
                        failure: function (response) {
                            alert(response.d);
                        },
                        error: function (response) {
                            alert(response.d);
                        }
                    });
                },

                "fnDrawCallback": function () {
                    $("#loadInProgressModal").modal("hide");
                },


                "initComplete": function (settings, json) {
                    yadcf.init(antennaTable,
         [
{
    column_number: 16,
    filter_type: "multi_select_custom_func",
    custom_func: antennastatusCustomFilterFunction,
    filter_container_id: "external_filter_container_antennastatus",
    filter_default_label: "Állapot szűrő (Fordított)",
    style_class: "antennalistFilter"
},
{
    column_number: 7,
    filter_type: "multi_select",
    filter_container_id: "external_filter_container_aag",
    filter_default_label: "Rendszer szűrő"
},
{
    column_number: 15,
    filter_type: "multi_select",
    filter_container_id: "external_filter_container_jelleg",
    filter_default_label: "Jelleg szűrő",
    style_class: "antennalistFilter"
},

         ],
         {
             onInitComplete: yadcf_OnInitComplete
         }
         );
                }
            });

Answers

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

    Hi @ZsoZ ,

    multi_select is just a YADCF filter_type, so nothing to do with DataTables as such, just the YADCF extension. I suspect they've added multi_select to those types are can be stateSaved, but didn't with multi_select_custom_func, presumably because since it's a custom function, it would be hard to know what needs to be saved. It would be worth asking on the YADCF forum/SO in case anyone knows (unless someone replies here in the meantime).

    Cheers,

    Colin

This discussion has been closed.