PDA

View Full Version : string together filters


ABC123

Steve Wood
08-02-2004, 03:00 PM
How do I string together two or more filters for a table within the A5W page source.

The following works for one parameter:
tmpl.DBF.filter = "Customer = \""+session.user_name + chr()34)

Tried this (and others) to string 2 parameters:
tmpl.DBF.filter = "Customer = \""+session.user_name\" .AND. Online_Ignore = .F. + chr(34)

Cheryl Lemire
08-02-2004, 03:33 PM
alltrim(timg.f_loc) + "/" + alltrim(timg.f_subdir) + "/" + alltrim(timg.f_filename) + "." + alltrim(timg.f_ext)

this is a string I am using in an application, maybe the sample will help you with yours?

Steve Wood
08-02-2004, 04:03 PM
I think its a different animal. The embedded quote thing is the trouble. I've had to do this before and it always throws me.

Selwyn Rabins
08-02-2004, 04:06 PM
tmpl.dbf.filter is a string.

so you must do:


tmpl.DBF.filter = "Customer = " + quote(session.user_name) + ".and. online_ignore = .f. "


if session.user_name is "fred" (for example) then the actual value of tmpl.dbf.filter is:

"customer = \"fred\" .and. online_ignore = .f."

which, as you see, is just a string.

to make the example richer, say that session.Ignore was a logical variable that contained the value for the 'online_ignore' field:



tmpl.DBF.filter = "Customer = " + quote(session.user_name) + ".and. online_ignore = " + s_quote(session.ignore)

s_quote() is a new v6 function that makes it very easy to create filter strings.

Steve Wood
08-02-2004, 04:23 PM
Thanks for both samples. On showing client the table online, they immediately said "great, but I don't want to see this or that record"; so I added the Online_Ignore checkbox to let them "Hide" records they don't want to see. Knowing how customers work, I expect to have to add a ShowAll button so they can un-hide those that they hid!

Steve Wood
08-03-2004, 12:46 AM
Just wanted to report how cool this is. I now have a column named Hide with a checkbox. The user can check off as many as they want. When they click the Update button, the screen refreshes and those records disappear from view.

Cheryl Lemire
08-03-2004, 04:54 AM
How were you able to accomplish your task?

Steve Wood
08-03-2004, 07:59 AM
Cheryl;

See the topic titled "Grid Builder filter value". Jerry gave me instructions on how to build a table filter outside of the Grid Builder Filter field. This was necessary because the Grid Builder Filter does not allow* for filters that use session variables.

* At least that is my understanding, and I bet it will allow this in the future.

The solution included 1) a Login page which took Username & Password and assigned the Username to a session variable. 2) a Logintest page that is called with a5w_include() in every page on my site. This checks that the person is logged in; if not, they are sent to the Login page. 3) The final filter for my table was...

tmpl.DBF.filter = "Customer = " + quote(session.user_name) + ".and. online_ignore = .f. "

... where Customers match the Username provided in the Login, and the online_ignore field is not True (not checked).

The Grid has an Update option, so when the user checks a online_ignore box, and clicks Update, those records are also filtered from view.

I think I could write this up in non-expert terms.

You are welcome to log in and see the result at:

support.attorneystrust.com

Username/password = "sowards" or "secure" or "kaplan".

(Limited to this week, the passwords will change.

Cheryl Lemire
08-03-2004, 08:11 AM
Great job. Thanks for the information, every piece of info is helpful :)