Change where in the grid application

hi,
I have a table that is displayed with a query like:
select * from table WHERE field1 = 10

through the search button off grid I want to change this filter, not add filter but change like

select * from table WHERE field2=80

what can I do?

I think that you can use a global variable to save your WHERE filter

first be sure to set your filter variable in onApplicationInit
[where_filter] = “true”;

and set your SQL to select * from table WHERE [where_filter]

Just change [where_filter] to whatever you want when needed

[where_filter] = “field1 = 10”

hi,
this solution may not work.
because SC would add what is put in onapplicationint.
exists sc_select_where (add) but just adds, there is nothing to overwrite the original where?

Don’t use sc_select_where (add), just reassign the global variable [where_filter] that you will create in onApplicationInit

it can’t work as you say, onApplicationInit is rerun every time you do a search…
as I said, something similar sc_select_where (add) would be needed, BUT to clean up the where

onApplicationInit is run one time when the app is loaded,

you only have to be sure that [where_filter] is declare, you can even declare at login if you want

reassing [where_filter] when needed, without using sc_select_where (add)

I just try it and it work fine

it can’t possibly work.
when you enter the app you would have the wrong filter and not the initial one

If you define the WHERE filter before entering the app you are right

so in this case define [where_filter] at login and use it at a session variable

sorry but you certainly do not solve the problem, I set it at login but then until I login again the value remains that of the filter.
it is definitely not the right solution, or rather it is not the result I want to do.

Don’t set it at login, create it at login with an initial value of [where_filter] = “true”;

Set it in your search button

we probably didn’t understand each other, mine is a normal Grid and the search is the standard search of SC

OK,

in your GRID set your SQL to: SELECT * from table WHERE [where_filter]

Set [where_filter] = “field1 = 10” or [where_filter] = “field2=80” in the onValidate of the search and pass it as a parameter to your grid

It work, I just try it

ok now in the same application go back to the grid and tell me which filter is applied?
not the original but the ones you set with the last search!

I don’t know the flow of solutions, but if you need to reset the WHERE after acceding your GRID, just set it back to the original value. Do it in onRecord, I know that it will be executed on each line, but at least it will be reset to whatever you want

if there is no macro of SC to reset the where is not possible, the search button inside of SC creates the WHERE by adding it to the existing one and it is impossible to delete or overwrite it, there is no way.
it would be nice to have an opinion from someone on the SC team

I hope I can help you. I open each grid with the search query active = 1. Via advanced search I can adjust that again to for example active = 0, or delete the search result completely. Are you looking for something like that?

Hi,
yes I would like to totally rewrite the where

Maybe this helps: Start filter grid application

hi,
sorry but for me it is never a good idea to touch the product code from sc.
bye

I do not edit the source code in the generated php file. My grids have been working this way for a year.