Return to first record/page after filtering.
Return to first record/page after filtering.
Hello all,
I’ve created a C# asp.net MVC 4.0 project in which I use datatables to display my data.
At the top of my I have a dropdown allowing uses to filter by regions. Then, I have an “Apply filter” button which makes an Ajax call to refresh the data.
The issue I currently have is the following:
Considering I have 26 records and display only 5 of them per page, I have 6 pages in the pagination.
The user decides to click on page 5. (Everything works great!)
At this point, the user selects from the dropdown, another region and clicks the “Apply filter” button.
Fortunately, 2 records exist but because I was on page 5 (prior to the filtering), it appears I’m still on page 5 but I need to manually click on the paging to go back to page 1 (to view those 2 records).
After a bit of digging and trials, I realized this is happening because I have the property:
bFilter set to false.
Yeah, I did this because I did not want to see the “Search textbox”.
If I set the bFilter to true, then the above scenario works propely…in other words, after applying a filter I automatically get back to page 1.
How can I achieve this behavior without having to view the “Search textbox” or keep bFilter set to false?
Sincerely
Thanks
I’ve created a C# asp.net MVC 4.0 project in which I use datatables to display my data.
At the top of my I have a dropdown allowing uses to filter by regions. Then, I have an “Apply filter” button which makes an Ajax call to refresh the data.
The issue I currently have is the following:
Considering I have 26 records and display only 5 of them per page, I have 6 pages in the pagination.
The user decides to click on page 5. (Everything works great!)
At this point, the user selects from the dropdown, another region and clicks the “Apply filter” button.
Fortunately, 2 records exist but because I was on page 5 (prior to the filtering), it appears I’m still on page 5 but I need to manually click on the paging to go back to page 1 (to view those 2 records).
After a bit of digging and trials, I realized this is happening because I have the property:
bFilter set to false.
Yeah, I did this because I did not want to see the “Search textbox”.
If I set the bFilter to true, then the above scenario works propely…in other words, after applying a filter I automatically get back to page 1.
How can I achieve this behavior without having to view the “Search textbox” or keep bFilter set to false?
Sincerely
Thanks
This discussion has been closed.
Replies
If you just want to remove the default filtering input use the sDom parameter and remove the 'f' option.
Allan