Using addTableFilterParam()

Questions, tips and tricks and techniques for scripting in Servoy

Using addTableFilterParam()

Postby maria » Fri May 22, 2009 2:16 am

This method behaves a bit strange. When I run a filter on application launch it's applied throughout the whole application successfully (except when I call a query to fill a dynamic value list).
Then at runtime I apply another filter to choose, for example, employees with names starting with 'w'. The filter is applied successfully.
And here is where the weird things happen. I open my search screen and search for employees with names starting with 'g'.

1. First of all, the 'g' employees are loaded in the search screen which is what I want but what I would not expect with my 'w' filter applied. The search is made by query (databaseManager.getDatasetByQuery()) and loaded in a form that uses a separate foundset.

The further the more weird things.
2. After I search for 'g' employees I select one of them for viewing and append this record to the foundset of my first screen that has that 'w' filter applied (I append it by getting the foundset's query, getting the dataset of the PKs with the help of this query and adding a row with the selected 'g' employee PK to it, then loading the resulting dataset in the form). And I still can see the 'w' employees together with the selected 'g' employee/ Why did the 'w' filter not exclude the 'g' employee from the list?

This behavior is exactly (well, with minor imperfections) what I want to implement but I don't understand why the filter works so strange.

(If I go to search again after selecting one 'g' employee and appending it to the 'w' list, and select another employee, say, 'r' employee, then the 'g' employee disappears from the list but the 'r' employee is still there. I would like to keep both of them and be able to add more).

Any ideas on what is going on behind the screen are most welcome.

3. And a bit of a conceptual question: is the method addTableFilterParam() supposed to be used on start up only or is it just another method to be played with at any place in the application. We are dealing with filters that the users are able to create, store and remove whenever they like. Is this method the best way to work with filters for us?

Cheers,
Maria
maria
 
Posts: 424
Joined: Thu Apr 16, 2009 1:18 am
Location: Sydney

Re: Using addTableFilterParam()

Postby rgansevles » Mon May 25, 2009 11:37 am

Maria,

Which version of Servoy are you using?

Rob
Rob Gansevles
Servoy
User avatar
rgansevles
 
Posts: 1927
Joined: Wed Nov 15, 2006 6:17 pm
Location: Amersfoort, NL

Re: Using addTableFilterParam()

Postby maria » Tue May 26, 2009 1:06 am

Hi Rob,

I'm using Version 4.1.2.i6 if this helps. Do you have any ideas?

Cheers,
Maria
maria
 
Posts: 424
Joined: Thu Apr 16, 2009 1:18 am
Location: Sydney

Re: Using addTableFilterParam()

Postby rgansevles » Tue May 26, 2009 3:57 pm

Maria,

The reason the filter did not remove the keys that did not match was because the records were already cached in the Servoy engine.
Servoy already had the data and filters are only applied when the database is queried.

This is an issue and will be fixed in next Servoy release.
This covers 1) and 2) I think

ad 3) Since Servoy 3.5 addTableFilterParam() can be used at any time in the application and apply to all non-custom sql queries.
When given a name, you can also remove them again with removeTableFilterParam().

Rob
Rob Gansevles
Servoy
User avatar
rgansevles
 
Posts: 1927
Joined: Wed Nov 15, 2006 6:17 pm
Location: Amersfoort, NL

Re: Using addTableFilterParam()

Postby maria » Wed May 27, 2009 1:27 am

Thanks Rob.

Does it mean that, in the next release, if the filters are applied to a foundset it is totally impossible to get filtered records until the filter is removed? There are situations like, for instance, we want to have a filtered foundset of records in a table view for a user but we still want the enable the user to search ALL records in a search window. For that, would it be a good practice to apply a filter to the foundset, then, when the user opens the search window, to remove the filter to show all records, and then to apply the filter again when the search window is closed (the window is modal)?

Cheers,
Maria
maria
 
Posts: 424
Joined: Thu Apr 16, 2009 1:18 am
Location: Sydney

Re: Using addTableFilterParam()

Postby juliaaano » Wed May 27, 2009 2:37 am

Hello everyone,

Please, see the topic viewtopic.php?f=22&t=12470#p63111 and tell me if we should use addTableFilterParam or something else like servoy find/search for that scenario.

Thank you.
Juliano Mohr
Information Analyst
The Service Manager (TSM)
Email: jmohr@theservicemanager.com
Website: http://www.theservicemanager.com
juliaaano
 
Posts: 66
Joined: Wed Apr 01, 2009 2:00 am
Location: Australia

Re: Using addTableFilterParam()

Postby rgansevles » Wed May 27, 2009 9:02 am

Maria,

Table filter params are designed to filter out data that should never be accessible by the user, all queries generated by Servoy (so not custom-queries) will have the condition included.
Although it can be applied any time and removed, best practice is to set them at client login and never remove them.

Rob
Rob Gansevles
Servoy
User avatar
rgansevles
 
Posts: 1927
Joined: Wed Nov 15, 2006 6:17 pm
Location: Amersfoort, NL

Re: Using addTableFilterParam()

Postby pbakker » Wed May 27, 2009 9:47 am

Hi Maria,

Maybe using foundsetfilters would be of help to you. A foundset filter applies to a specific foundset and can be removed by calling loadAllRecords() on that specific foundset object.

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Re: Using addTableFilterParam()

Postby Gary R. Schaecher » Wed May 27, 2009 4:05 pm

Paul, we have been trying for 3 days to remove a foundset filter and we also tried loadAllRecords which didn't do the job. You might email Lenore if you know some trick we don't.

Gary
Gary R. Schaecher
TMA Systems, LLC
www.tmasystems.com
Gary R. Schaecher
 
Posts: 72
Joined: Sat Jan 06, 2007 11:01 pm

Re: Using addTableFilterParam()

Postby Lenore » Wed May 27, 2009 9:30 pm

Can you explain the advantages and disadvantages of using a foundsetfilter vs a tablefilter? The tablefilter has getTableFilterParam and removeTableFilterParams that the foundset doesn't.
Lenore Marlow
TMA Systems, LLC
www.tmasystems.com
Lenore
 
Posts: 27
Joined: Fri May 11, 2007 3:18 pm
Location: Tulsa, OK

Re: Using addTableFilterParam()

Postby pbakker » Thu May 28, 2009 10:33 am

I stand corrected on what I said before: a loadAllRecords() on a foundset with FoundSetFilters applied will not remove the filters.

Currently, FoundSetFilters, once set, are permanent for that specific FoundSet object.

What you can do is create a new FoundSet object using "var FoundSetObject = databaseManager.getFoundSet(...);" and load that FoundSet into your form using "controller.loadRecords(FoundSetObject);"

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Re: Using addTableFilterParam()

Postby pbakker » Thu May 28, 2009 10:37 am

The difference between a tableFilter and a FoundSetFilter is that a FoundSetFilter applies only to 1 specific FoundSet.

So if you have 10 different FoundSets on the Customers table and you apply a FoundSetFilter to one of the FoundSets, only that specific FoundSet instance is affected.

If you would apply the same filter but using the tableFilter functionality, then the Filter would be applied to all FoundSet instances.

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Re: Using addTableFilterParam()

Postby ROCLASI » Thu May 28, 2009 10:46 am

Hi Paul,

pbakker wrote:What you can do is create a new FoundSet object using "var FoundSetObject = databaseManager.getFoundSet(...);" and load that FoundSet into your form using "controller.loadRecords(FoundSetObject);"


Wouldn't that create a 'seperate' foundset? I.e. if you had a list and detail form using the same foundset and you set the list form foundset to this new foundset object then the detail form would not be linked to this list form anymore?
Or am I mistaken?
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: Using addTableFilterParam()

Postby pbakker » Thu May 28, 2009 10:58 am

Right, you'd have to set teh new FoundSet object into both the list and detail view.

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Re: Using addTableFilterParam()

Postby Lenore » Thu May 28, 2009 3:17 pm

That sure does sound like a lot of trouble. This just does not seem to be a viable solution for us. We have this situation throughout our application and also have this complicated with record locking, databroadcasting and record validation. Why can't we just have the commands removeFoundSetFilterParam and getFoundSetFilterParams so we can handle this on our own? BTW, we put in a case for this as a feature request. I hope the Servoy developers see the need as we do.
Lenore Marlow
TMA Systems, LLC
www.tmasystems.com
Lenore
 
Posts: 27
Joined: Fri May 11, 2007 3:18 pm
Location: Tulsa, OK

Next

Return to Methods

Who is online

Users browsing this forum: No registered users and 29 guests