How can I make the search box of DataTables retain search records?

How can I make the search box of DataTables retain search records?

hhhhhhhhhhhh Posts: 1Questions: 1Answers: 0
edited June 23 in Free community support
table = $('.dataTables-example').DataTable({
            pageLength: 25,
            responsive: true,
            // searching:false,
            dom: '<"html5buttons"B>lTfgitp',
            buttons: [
                {extend: 'copy',text:"复制"},
                {extend: 'excel', title: 'ExampleFile',text:"导出excel"},
                {extend: 'pdf', title: 'ExampleFile',text:"导出pdf"},
                {extend: 'print',text:"打印",
                    customize: function (win){
                        $(win.document.body).addClass('white-bg');
                        $(win.document.body).css('font-size', '10px');

                        $(win.document.body).find('table')
                                .addClass('compact')
                                .css('font-size', 'inherit');
                    }
                }],
            language: {
                "sProcessing": "处理中...",
                "sLengthMenu": "显示 _MENU_ 项搜索结果",
                "sZeroRecords": "没有匹配结果",
                "sInfo": "显示第 _START_ 至 _END_ 项结果,共 _TOTAL_ 条数据",
                "sInfoEmpty": "显示第 0 至 0 项结果,共 0 项",
                "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
                "sInfoPostFix": "",
                "sSearch": "搜索:",
                "sUrl": "",
                "sEmptyTable": "未搜索到数据",
                "sLoadingRecords": "载入中...",
                "sInfoThousands": ",",
                "oPaginate": {
                    "sFirst": "首页",
                    "sPrevious": "上页",
                    "sNext": "下页",
                    "sLast": "末页"
                },
                "oAria": {
                    "sSortAscending": ": 以升序排列此列",
                    "sSortDescending": ": 以降序排列此列"
                }
})

Description of problem: I want to make the search box of DataTables retain the historical search records, but I don't know how to complete it.

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

Answers

  • allanallan Posts: 56,203Questions: 1Answers: 8,902 Site admin

    That isn't a feature of DataTables I'm afraid. It would require a custom input box using something like Select2, and have it call the search() method, rather than using the built in search box.

    Allan

Sign In or Register to comment.