i have searchbuilder, in addition i want to add a custom filter button

i have searchbuilder, in addition i want to add a custom filter button

umaeswaraumaeswara Posts: 85Questions: 17Answers: 0

https://live.datatables.net/dimipoma/1/edit my testcase.
i have already a working searchbuilder. I want to add one more custom filter button name "current year", which when I click on this button filters and shows all rows with Dates with 2025 as their year.

how can I achive this.

thank you.

Answers

  • allanallan Posts: 63,872Questions: 1Answers: 10,527 Site admin

    This page has details on how to create a custom button. Use the column().search() method to set a search for the column in question. Given the format, you could just pass the string for the current year (which you can get from the new Date() object).

    Allan

  • umaeswaraumaeswara Posts: 85Questions: 17Answers: 0

    hi Allan, thanks for reply. i have edited my example with buttons []. but it didnt show any button. please check and help me.
    https://live.datatables.net/dimipoma/1/edit
    thanks,
    Uma-

  • kthorngrenkthorngren Posts: 21,571Questions: 26Answers: 4,996
    edited January 24

    First you need to add the buttons library to the CDN includes you have. Open the .js CDN link and use the upgrade URL provided to add the buttons, for example:

    * To rebuild or modify this file with the latest versions of the included
     * software please visit:
     *   https://datatables.net/download/#dt/dt-2.1.8/date-1.5.4/sb-1.8.1/sr-1.4.1
     *
    

    For a custom button all you need to add is the Buttons option.

    Next update the layout option to display the buttons where you want. See the Buttons initialization docs and this example for more details.

    Updated test case:
    https://live.datatables.net/dimipoma/2/edit

    Kevin

Sign In or Register to comment.