简体   繁体   中英

how to filter search by value in button text using jquery datatable

How can i filter search by using value button here is my jquery code

<script>
$(document).ready(function() {

$('#myTable').DataTable({
    dom: 'Bfrtip',
    buttons: [
        {
            text: "text1",
            action: function(e, dt, node, config){
                dt.column(0).search("text1").draw();
            }
        },
        {
            text: "text2",
            action: function(e, dt, node, config){
                dt.column(0).search("text2").draw();
            }
        },
        {
            text: "text3",
            action: function(e, dt, node, config){
                dt.column(0).search("text3").draw();
            }
        }
    ]

})

});
</script>

I want to click button text1 and datatable will search text1 value

According to the documentation , the dt parameter should be an instance of the DataTable API, which has a search() method.

So try the following:

dt.search('text1').draw()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM