How? Filter (or search?) table by click on cell

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
onoehring
Veteran Member
Posts: 102
Joined: 2019-05-21 22:42

How? Filter (or search?) table by click on cell

Post by onoehring » 2019-06-08 08:11

Hi,

I want to
a) either filter
b) search
directly by clicking on a cell in a table.

I try to give an example

Code: Select all

ID | Description | Area | Class | 
---+-------------+------+-------+
1  | my value 1  | ABC  |  556  | 
2  | my value 2  | ABC  |  778  |
3  | my value 3  | DEF  |  778  |
4  | my value 4  | DEF  |  556  |
Now,
when I click in column AREA on ABC, only records that are equal to ABC are left in the rows (which would be 1 and 2)
when I click in column Class on 556, only records 1 and 4 would be left.

How can I accomplish that?

Olaf

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 446
Joined: 2018-04-01 10:12

Re: How? Filter (or search?) table by click on cell

Post by pböttcher » 2019-06-08 14:34

Hi,

just a question to this. How would you like to get to the detail records if you make the all the "links" to the details as filters?

onoehring
Veteran Member
Posts: 102
Joined: 2019-05-21 22:42

Re: How? Filter (or search?) table by click on cell

Post by onoehring » 2019-06-09 06:26

Hi pbötcher,

question accepted - but actually for my case irrelevant.
a) I need to have this option on ONE column only - that's enough. So actually, I would need to define which column needs this function.
I agree, that it's nice, that one can click on any column, but this "one" column should have a different behavior.
As the application will be used mostly on tablets, it would be easier (in my context and customer asked for this) if one could search for description and then click on an Area to see all items in that are - instead of setting up a filter (general filter is too specific, search page maker does not create a search for my field as it is Autofill (see viewtopic.php?f=11&t=3041 )

b) the user can only edit that one column. No other details are shown when an item is selected.

I though maybe putting a link on that item in the media section - but this does not seem to be an option (see screenshot).
Maybe it would be of some help already, if there is a way to create a filter with a link ( viewtopic.php?f=2&t=3051 ). This way, I could probably tweak the table output to include that link instead of a link to details.
ec10.png
ec10.png (84.57 KiB) Viewed 147 times
Olaf

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 446
Joined: 2018-04-01 10:12

Re: How? Filter (or search?) table by click on cell

Post by pböttcher » 2019-06-09 09:54

Hi,

you can try this:

put in your hooks/TABLENAME-tv.js file:

Code: Select all

$j(function () {
	var filter='TABLENAME_view.php?SortField=&SortDirection=&FilterAnd[1]=and&FilterField[1]=FIELDCOUNT&FilterOperator[1]=equal-to&FilterValue[1]=';
	$j('[id*=TABLENAME-FIELDNAME] a').each(function() { $j(this).attr('href', filter + $j(this).text() ).removeAttr( "onclick" );});
  });
You need to replace

TABLENAME = your table to which you want to apply (in your sample I would assume ecomo_Container)
FIELDNAME = name of the field (in your sample I would assume ID_Location)
FIELDCOUNT = Position of your field in the AppGini definition (in your sample I would assume 3)

in the above code.

onoehring
Veteran Member
Posts: 102
Joined: 2019-05-21 22:42

Re: How? Filter (or search?) table by click on cell

Post by onoehring » 2019-06-09 12:25

Hi pböttcher,

this looks good and works! Great. Thanks a lot.

Can I add more sort-options (like sort row A asc and then B desc?)
Can I add more colums to the filter (like: first the user clicks on AREA, then, after it's filtered to AREA he clicks on CLASS)?

Olaf

onoehring
Veteran Member
Posts: 102
Joined: 2019-05-21 22:42

Re: How? Filter (or search?) table by click on cell

Post by onoehring » 2019-06-09 12:56

Hi,

ok, found how to add sorts: Create advanced filter and save that filter -> here, one can see the syntax.
(Have not tried for filter yet).

Olaf

onoehring
Veteran Member
Posts: 102
Joined: 2019-05-21 22:42

Re: How? Filter (or search?) table by click on cell

Post by onoehring » 2019-06-11 04:30

Hi,

i did change my application (table / column layout) to achieve the filter effect with two other columns.
Thank you again.

Olaf

onoehring
Veteran Member
Posts: 102
Joined: 2019-05-21 22:42

Re: How? Filter (or search?) table by click on cell

Post by onoehring » 2019-06-17 11:02

Hi,

I want to widen the question a little more.
Is it possible using pbötchers suggested code ( viewtopic.php?f=2&t=3049#p10145 ) and extend the filter by adding a new column to it?
Example: In my table above, imagine the user clicks on a cell in the AREA column to filter for that contents.
Afterwards the user wants to set an additional filter to an entry in the CLASS column - again by clicking on that cell entry.

How can I add something to the existing (i.e. already applied) filter/sort options.

Would it be possible to simply change the [1] in pbötchers code to [2] or is there more/other code needed?

Olaf

Post Reply