1. Daniel Vivier
  2. PowerBuilder
  3. Friday, 21 December 2018 17:08 PM UTC

We use the built-in Filter window to allow users of our software to filter reports.

We have run into a problem where occasionally users somehow get curly quotes (like “this”) into filter expressions and then of course they don't work. One way that could happen is if users are typing a proposed filter in an email in Outlook, which generates those type of quotes by default, and then what they type is cut and pasted into the filter window. A user running our app on a Mac, running Windows under Parallels, also told us that her keyboard was doing that automatically right in the Filter window.

What I'd like to do is my own pre-validation of filter expressions, before PB gets to them, so that I could replace single or double curly quotes with proper straight quotes. But I'm pretty sure there's no way to do so.

Any suggestions? (No, I don't want to adopt a large framework that has a replacement for the filter window, though I would certainly accept a stand-alone look-alike replacement!)

Thanks.

Miguel Leeuwe Accepted Answer Pending Moderation
  1. Thursday, 3 January 2019 00:49 AM UTC
  2. PowerBuilder
  3. # 1

I've used the pfc filter simple window and don't like the way it populates the dddw's. It takes the sql and then repeats every select to populate them. In our case that was too slow, since the original select of the dw to be filtered already was a bit slow. It's much better to do something else like NOT populating the dddw's and just let the user type what he/she's looking for, untill the user decides he wants an existing value and therefore clicks on the arrows to show the dddw. In that case I scan the values of the already retrieved dw to populate the different values, rather than doing retrieves.

Just a tip if you decide to use the pfc filter window.

Comment
There are no comments made yet.
Brad Mettee Accepted Answer Pending Moderation
  1. Friday, 28 December 2018 13:55 PM UTC
  2. PowerBuilder
  3. # 2

Dan,

You may want to consider putting in a popup prior to the filter window opening that explains the different issues they may run into. Give clear examples of what's ok to use, and what will certainly fail. Give them an option in settings so they can turn the reminder off. Do NOT put a checkbox on the tip window to prevent it opening, they'll likely not read the window, and just tick it and keep going.

It would be helpful to submit a request for a new event "preValidate" so we could inspect the string and make any automagic adjustments prior to it's being parsed.

Comment
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Thursday, 27 December 2018 21:29 PM UTC
  2. PowerBuilder
  3. # 3

If you end up coding your own filter window, there is a Windows API function that will clean the text.

https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-chartooemw

 

Comment
There are no comments made yet.
Matthew Balent Accepted Answer Pending Moderation
  1. Thursday, 27 December 2018 19:02 PM UTC
  2. PowerBuilder
  3. # 4

From your description it sounds like you need a method to 'cleanse' a string to either eliminate or substitute 'bad' characters.  If this is the case you would need to accept the input then run it one character at a time through your method and return the character to be put back into the string.

One approach I have seen for this is to look at the ASCII values of the string (assuming you are not using Unicode) and eliminate (return an empty string or '') everything outside the range of values for lower and uppercase letters, numbers, and whatever other characters you deem acceptable.

So then the user cuts and pastes bad string into your app, app takes the string and 'cleans' it, 'clean' string is put into the control the user put his stuff, 'clean' string is put into the filter, filtering is done, etc.

Comment
  1. Daniel Vivier
  2. Thursday, 27 December 2018 20:14 PM UTC
Matthew, I know how to write code like that. The problem is if we send a user to PB's built-in Filter definition window, they can't get out of it with invalid filters, such as ones including curly quotes instead of straight quotes.
  1. Helpful
There are no comments made yet.
Brad Wery Accepted Answer Pending Moderation
  1. Thursday, 27 December 2018 17:42 PM UTC
  2. PowerBuilder
  3. # 5

Dan,

Have you had a chance to look at PowerFilter?

http://powerbuilderui.com/powerfilter.html

 

Comment
  1. Daniel Vivier
  2. Thursday, 27 December 2018 20:15 PM UTC
Thanks, Brad. From the one screen shot on their site (which seems rather minimal!) it looks like it would make our reports look too techie for our users, many of whom are not very sophisticated computer users.
  1. Helpful
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Sunday, 23 December 2018 00:29 AM UTC
  2. PowerBuilder
  3. # 6

I do understand, but if you take the just a little bit of time you'll find that the FilterWindow piece is pretty much self-contained.

Still, I get it....  :)

 

Olan

 

Comment
  1. Daniel Vivier
  2. Thursday, 27 December 2018 20:16 PM UTC
I'm looking now at the pfc_w_filtersimple window and may try to do something much like that, or extract it and pieces it uses into our code if that's not too hard.
  1. Helpful
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Saturday, 22 December 2018 22:24 PM UTC
  2. PowerBuilder
  3. # 7

Dan, this is simple to do.

1) Create a new FilterWindow, inherited from pfc_FilterWindow window.

2) I cannot recall whether or not there are SLEs or DWs for the various fields, but in whichever event equates to the ItemChanged event, you call your validation routine and make any changes required.

After the new year I will try to remember to post better details.

 

 

Oln

Comment
  1. Daniel Vivier
  2. Sunday, 23 December 2018 00:13 AM UTC
Thanks, Olan, but as I said, I don't want to adopt a large framework like the PFC, or have to download it and figure out how to extract only the parts I need for that one purpose. My memory of learning a bit about the PFC (which I've never used) is that everything is all tightly bound together, so you can't easily just pull out one feature.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.