need to $watch internal filterText & sLength variables

need to $watch internal filterText & sLength variables

ajoslin103ajoslin103 Posts: 20Questions: 4Answers: 0

I need to know when the user has changed the filter/search text and when they have changed the [page] length

How can I accomplish this?

Ideally I will use the Angular $watch function to do it

thanks
al;

Replies

  • allanallan Posts: 61,446Questions: 1Answers: 10,055 Site admin

    DataTables triggers events to let you know when state has changed:

    Allan

  • ajoslin103ajoslin103 Posts: 20Questions: 4Answers: 0

    I used search.dt & length.dt -- they work great

    Question now is, how can I set the search text programatically ?

  • allanallan Posts: 61,446Questions: 1Answers: 10,055 Site admin

    Use filter() and column().filter() .

    The full reference contains a list of all options, API methods and events.

    Allan

  • ajoslin103ajoslin103 Posts: 20Questions: 4Answers: 0

    sorry, to be more clear. I am using localBrowserStorage to return the table and associated controls to the state the user left them in. So by saving the values from the last of these events I can init the table with them next time. Except for the search term that the user typed into the search box. But I think I've got that one with plain old DOM-javascript. I just have to debounce the search term events as those come in after each key typed and I only want it from a second or so after they stop typing.

    I have to handle returning the table to the proper page as well

  • allanallan Posts: 61,446Questions: 1Answers: 10,055 Site admin

    Except for the search term that the user typed into the search box

    This is a column filter control, or an external global filter control is it? Currently you need to use settings() and read the object oLoadedState to restore the state. I'm going to be reworking the state saving tomorrow and adding a new API method to get the saved state so you can restore your custom filters. The new method will be in 1.10.1.

    Allan

This discussion has been closed.