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
User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

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

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

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

Post by pbottcher » 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?
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

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 3823 times
Olaf

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

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

Post by pbottcher » 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.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

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

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

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

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

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

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

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

sacgtdev
Veteran Member
Posts: 75
Joined: 2020-06-10 11:14

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

Post by sacgtdev » 2021-08-04 08:57

I have a slightly difference question.

Is there a way to encode a permalink for multiple ids?

something like filter with ids in {1,2,4,5,7}

SkayyHH
Veteran Member
Posts: 425
Joined: 2015-04-27 21:18

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

Post by SkayyHH » 2021-08-06 14:09

Hi

this is very interesting. I would also be happy to see if this cool function can be expanded into several columns :-)

Many greetings, Kai

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

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

Post by onoehring » 2021-08-22 09:51

Hi,

I want to reply to sacgtdev's question
Is there a way to encode a permalink for multiple ids?

something like filter with ids in {1,2,4,5,7}
Sure you can: Just write a function, that take an URL argument (like "mysuperfilter") and create a filter using php from the options this argument has.
Something like (pseudo code):

Code: Select all

myfilterarray = split(mysuperfilter,",")           // split argument by ","
foreach myfilterarray {
$filtervar = "AND yourID=" . myfilterarray[key]         //where myfilterarray[key] holds the number your variable/argument provided
}
Just an idea...

Olaf

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

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

Post by pbottcher » 2021-08-23 16:09

Hi,

have a look at

https://bigprof.com/appgini/help/advanc ... ch-actions

function print_mail_labels
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

sacgtdev
Veteran Member
Posts: 75
Joined: 2020-06-10 11:14

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

Post by sacgtdev » 2021-08-25 04:09

I think if using the same id columns for filtering multiple ids, it has to use 'OR' instead of 'AND".

Is there a limitation on url length? max is how many characters?


Post Reply