Page 1 of 1

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

Posted: 2019-06-08 08:11
by onoehring
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

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

Posted: 2019-06-08 14:34
by pbottcher
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?

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

Posted: 2019-06-09 06:26
by onoehring
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 3916 times
Olaf

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

Posted: 2019-06-09 09:54
by pbottcher
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.

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

Posted: 2019-06-09 12:25
by onoehring
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

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

Posted: 2019-06-09 12:56
by onoehring
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

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

Posted: 2019-06-11 04:30
by onoehring
Hi,

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

Olaf

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

Posted: 2019-06-17 11:02
by onoehring
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

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

Posted: 2021-08-04 08:57
by sacgtdev
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}

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

Posted: 2021-08-06 14:09
by SkayyHH
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

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

Posted: 2021-08-22 09:51
by onoehring
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

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

Posted: 2021-08-23 16:09
by pbottcher
Hi,

have a look at

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

function print_mail_labels

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

Posted: 2021-08-25 04:09
by sacgtdev
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?

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

Posted: 2021-08-25 15:55
by onoehring
Hi

URL length is limited to 2 kb I believe (max GET size, see https://www.w3schools.com/tags/ref_httpmethods.asp)

Olaf