DataTables Custom Buttton and Column Searching

DataTables Custom Buttton and Column Searching

david.j.meyer2@boeing.comdavid.j.meyer2@boeing.com Posts: 54Questions: 15Answers: 0

I have a databtable with 15 columns and I am using server side processing because the table has 400K rows.

I have 4 columns in this datatable that have input boxes in the footer for user filtering.

I do not want to filter on Key Up event, instead i have added a custom button called filter.

The desired behavior would be for the user to type in filtering data to multiple columns and then filter the data all at once by clicking the new button.

Any idea how i could do this? Is there an example I can look at that performs more customized searching?

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,447Questions: 26Answers: 4,974
    Answer ✓

    You can use the search() or column().search() in a button click event. I built a simplified version (no inputs) to demonstrate:
    http://live.datatables.net/zeliyido/1/edit

    Note that the click event performs two column searches but uses draw only once. You can look at the XHR request Headers in the Developer Tools > Network tool and see the request has the search term for both columns:

    columns[2][data]: 2
    columns[2][name]: 
    columns[2][searchable]: true
    columns[2][orderable]: true
    columns[2][search][value]: Software Engineer
    columns[2][search][regex]: false
    columns[3][data]: 3
    columns[3][name]: 
    columns[3][searchable]: true
    columns[3][orderable]: true
    columns[3][search][value]: London
    columns[3][search][regex]: false
    

    The server side script used appears to use an AND for the SQL Query. Depending on your solution requirements you may need to use an OR search query.

    Kevin

  • david.j.meyer2@boeing.comdavid.j.meyer2@boeing.com Posts: 54Questions: 15Answers: 0

    Thank you.

This discussion has been closed.