Custom Search using DataTable API issue

Custom Search using DataTable API issue

bumblebeebumblebee Posts: 18Questions: 5Answers: 0
edited September 2016 in Free community support

I am using DataTable along with AngularJS. I do have a custom search field that uses the API to filter the table.
It works fine when I visit the page the first time

I have a directive that looks for the table id and does the search using the API

The issue is when I navigate to another page and come back to the page which has the custom search, then do the search, nothing happens. I do see the my directive does access the API and the data is in there for it to do a search, but it does not refresh the Table.

Earlier I had the default search box hidden. When I enable it, and use that to search when I visit the page after navigating to other pages I see it works.

So it is my custom field that uses the API is having issue.

Any suggestion on what I might add. I do have the timeout and apply functions added as well.

           var st=scope.search;
           $timeout(function() {
               element.ready(function () {
                   scope.$apply(function () {
        table.search(st).draw();

                   });
               });

           }, 0);

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,815Questions: 1Answers: 10,517 Site admin

    Thanks for your question - however, per the forum rules can you link to a test case showing the issue please. This will allow the issue to be debugged.

    Information on how to create a test page, if you can't provide a link to your own page can be found here.

    Thanks,
    Allan

  • bumblebeebumblebee Posts: 18Questions: 5Answers: 0

    Hi Alan,

    Here is the code asixoj the debugger provided.

    Bumblebee

  • allanallan Posts: 63,815Questions: 1Answers: 10,517 Site admin
    Answer ✓

    Thanks - however, in this case I think I would need an actual test case.

    Allan

  • bumblebeebumblebee Posts: 18Questions: 5Answers: 0
    edited September 2016

    I solved it by initializing the table every time one comes to the page. Thank you

This discussion has been closed.