Searchbuilder - set criteria dynamically

Searchbuilder - set criteria dynamically

amacourekamacourek Posts: 15Questions: 2Answers: 0

Can someone please point me to the documentation for setting the criteria dynamically? I have several criteria options for the user to choose and would like to change on the fly.

Answers

  • kthorngrenkthorngren Posts: 21,336Questions: 26Answers: 4,951

    Are you wanting to do something like this example?

    Kevin

  • amacourekamacourek Posts: 15Questions: 2Answers: 0

    Thanks for the reply, but I already have another implementation where I set the preDefined criteria on initialization. That is not the problem. I want to change the criteria post-initialization.

  • kthorngrenkthorngren Posts: 21,336Questions: 26Answers: 4,951

    Maybe this example is what you are looking for.

    Kevin

  • amacourekamacourek Posts: 15Questions: 2Answers: 0

    Again, thanks. However, this is not what I wanted. The latest example goes back to a snapshot. What I wanted was after a datatable/searchbuilder is initialized, call a method that passes a criteria definition and updates with what is provided. I guess I might just have to re-initialize the DT/SB each time.

  • kthorngrenkthorngren Posts: 21,336Questions: 26Answers: 4,951

    The key thing that example shows is the use of searchBuilder.rebuild(). This is both a getter and setter. You can update the search criteria using searchBuilder.rebuild(). I updated the example in the docs to include adding a criteria to the current search.
    https://live.datatables.net/talosuye/1/edit

    Perform a search, Position = Developer for example. Then click the Edinburgh button to see the Office = Edinburgh criteria added to the current search criteria. The Get Details and Edinburgh buttons output the search criteria so you can see the data structure.

    Is this what you are looking for?

    Kevin

Sign In or Register to comment.