Trouble with custom filtering + pagination reset in DataTables !!

Trouble with custom filtering + pagination reset in DataTables !!

marcellosalasmarcellosalas Posts: 2Questions: 2Answers: 0

Hi everyone,

I am currently working on a project using DataTables and have run into an issue I can’t quite figure out. I am implementing a custom filter (outside the default search box) to filter rows based on a specific column. The filter itself works fine..., but whenever I apply it, the pagination doesn’t reset to the first page — so if I’m on page 3 and the filtered result only has 1 page, it shows “No data available” until I manually go back to page 1.

Here’s a snippet of how I am triggering the redraw :-

table.draw();

I tried using table.page('first').draw('page');, but it doesn’t seem consistent.

Has anyone faced a similar issue: ?? What’s the best practice to ensure the pagination resets properly after a custom filter is applied: ?? I have also read this thread https://datatables.net/forums/discussion/75915/custom-filtering-why-is-my-filter-not-being-cleared-snowflake-training-in-hyderabad but still looking for some more help.

Appreciate any help!

Thanks in advance.

Marcelo

Answers

  • kthorngrenkthorngren Posts: 22,088Questions: 26Answers: 5,092

    Just a guess that you are using server side processing (serverSide: true) and the server script isn't returning the correct info. Are you using server side processing?

    If yes then start by using the browser's network inspector to inspect the JSON response when performing a search. Likely the server script will need to be debugged. Are you using a Datatables supplied server side processing script?

    Check the browser's console for errors when performing the search. Do you see any?

    I built this simple server side processing test case:
    https://live.datatables.net/yaroyala/111/edit

    Navigate to page 3 then click the search button. The search works and page 1 is displayed.

    If you still need help debugging then lease post a link to your page or a test case replicating the issue.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

Sign In or Register to comment.