If you have questions or if you want to share your opinion about Aware IM post your message on this forum
#54010 by fazman
Tue Jun 02, 2020 8:53 am
I'm not really sure where to post this or if it is of use/ relevant - so apologies if this is in the wrong place
I searched the forum earlier because I was wanting to find a way to do this - but not finding anything, I read through the guides and kendo docs and came up with a solution.

The problem:
In some instances, I need to "pre" filter a query - for example, I want to show only active records when a query is first displayed - but I want the user to be able to override this if they need to - so a where clause is out, and I really don't want to create a separate query for active/inactive etc

The solution:
This is a render script to be used on the query:

var grid = widget;
var ds=grid.dataSource;
ds.filter( {
logic: "and",
filters: [
{field: "fieldName", operator: "operator - eg eq/neq ... ", value: "value" },
{field: "IsActive", operator: "eq", value: "Yes" }
]
});

Hopefully I've given enough detail to help you understand what I'm saying

One final note - I found that the abbreviated versions of the operators - ie eq as opposed to equals, seem to work better, although there was a bit of trial and error getting all the format right so I should probably test that again.

Hope someone finds it useful
#54012 by eagles9999
Tue Jun 02, 2020 9:59 am
I would do it something like this.....

In the RegularUser BO add an Attribute called MyQueryFilter PLAIN TEXT with Default Value 'ACTIVE' and Options of 'ACTIVE' and 'ALL'

The Query is called 'MyAwesomeQuery' will look like this...

FIND MyData WHERE((MyData.Status='Active' AND LoggedInRegularUser.MyQueryFilter='ACTIVE') OR LoggedInRegularUser.MyQueryFilter='ALL')

Create a Process called ToggleQueryFilter
IF LoggedInRegularUser.MyQueryFilter='ACTIVE' THEN
LoggedInRegularUser.MyQueryFilter='ALL'
ELSE
LoggedInRegularUser.MyQueryFilter='ACTIVE'

Create a Panel Operation Button on Top Panel of the Query called, say, Toggle Filter which calls this Process

To Display the Query .... Create a Process DISPLAYMyAwesomeQuery
LoggedInRegularUser.MyQueryFilter='ACTIVE'
DISPLAY 'MyAwesomeQuery'

Then add tom the refresh rules of the Query...... MyData and the Process ToggleQueryFilter


Here is a litte demo of the above....

(39.24 KiB) Downloaded 29 times
#54113 by Jaymer
Tue Jun 16, 2020 12:03 am
this is DAMN Useful !!!! Thanks for knocking this out.
And its been needed for a long time.
Took me 2 minutes and worked first time.

Its a pain to have to make redundant queries - 1 for All Customers, and another for Only Active -- just to save the users from having to constantly enter a filter. Filtering is easy - but users get tired of it if they have to constantly enter the same stuff many times a day (since we don't have a elegant way for saved user-filters).

And I've used Mark's method plenty of times - but thats still a hassle to get done with temp fields needed and Processes to toggle, etc.
(Mark's method will be easier in the next version because you will have a in-memory set of temp fields available - so these will NOT have to be constantly written to LIRU)

I only needed 1 field, so haven't played with this much.

Code: Select allvar grid = widget;
var ds=grid.dataSource;
ds.filter( {
logic: "and",
filters: [
{field: "ActiveYN", operator: "eq", value: "Y" }
]
});


--> JaymerTip pre-filter a Query with clearable filter values

Who is online

Users browsing this forum: Google [Bot] and 29 guests