Apply a default filter on a table

Discussions related to customizing hooks. Hooks are documented at
Post Reply
A Bindi
Posts: 10
Joined: 2018-01-04 18:45

Apply a default filter on a table

Post by A Bindi » 2019-01-16 14:31

I applied the interesting article "Applying a default filter on a table" ( ... ult-filter) modifying the tablename_init hook as described, and indeed it seems to run correctly, but a problem appears when iI want to remove the filter to see all the records.

Pratically when i click on "Show All" button all records are correctly shown, BUT only on first page ! In fact when i switch on second page the table is listed with the filter applied again; if in that second page I click on "Show All" button again the first page is re-listed. :(

Is there a solution ?


Veteran Member
Posts: 84
Joined: 2018-05-23 09:32

Re: Apply a default filter on a table

Post by sjohn » 2019-01-17 11:48

This is a catch 22 - but as it is an initial filter, then when paging the same thing happens as with eventual "marked/checked" records - it is a new page-load.

If it is a table with not too many records, you could maybe use the fantastic "scroll" suggested by pböttcher : ... f=4&t=2673

You could have the scrolling for 50-100 records and still have the paging. But the problem with paging will still be there.

Another way is to make a view in a "parallel" table that is filtered. But then the initial filtering will be there always. You can still filter, but it will be in the filtered table.

The normal unfiltered table will still be available, so you could have two tables shown - one with the pre-defined filtering and the other without. You still only have to maintain one table.

If the static filter is not an option, then I think you need some code that can check if you are on page 1 or not, and then only let the filter be active on page 1. This will also mean that when paging back to page one, the filter will be active again.
I cannot help with such eventual code.

A Bindi
Posts: 10
Joined: 2018-01-04 18:45

Re: Apply a default filter on a table

Post by A Bindi » 2019-01-23 15:04

Thank you very much for suggestions, very intersting.

Unfortunately it seems to do not exists a real solution to the problem, only workarounds ... :(


User avatar
Site Admin
Posts: 1021
Joined: 2012-09-27 14:46

Re: Apply a default filter on a table

Post by a.gneady » 2019-01-24 14:26

Hmm ... If I understand correctly, you don't want to force the initial filter ... you just want it to be an optional default filter applied when users initially access the table, but they can choose to remove it and see all records. In this case, a better approach instead of the code in the tablename_init hook is to modify the link to the table in the homepage and the navigation menu ... It can be done through JavaScript code placed in hooks/footer-extras.php ... something like this:

Code: Select all

	$j(function() {
		// change the link below to your desired initial filter
		var filteredLink = 'tablename_view.php?FilterField[1]=3& ...';

		$j('[href^="tablename_view.php"]').attr('href', filteredLink);
Change tablename above to the concerned table name and change the filter link to the desired initial filter.
:idea: Learn all the tips and tricks of customizing AppGini apps through our online course.

:arrow: Mass Update plugin: Update multiple records at once and improve your workflow efficiency.

:arrow: Summary Reports plugin: Build powerful reports and charts for your AppGini apps.

:arrow: Search Page Maker: Compose user-friendly yet powerful search pages for your AppGini apps.

Post Reply