Change where in the grid application

Hi,

I assume you mean the advanced search?

If so what I tend to do is the following:
I create custom search fields in the search section. I then in my grid applications onScriptInt create a custom where clause variable called [custom_where].
Then I just assign it a value like “WHERE field2=80” and add it to the where clause using sc_select_where(add).

I would also remove the original where clause from the grid and move it in to the grid onScriptInt event.

So your code would look something like this:
Grid onScriptInt event:

if([search_was_done] != 1)
{
[custom_where] = “WHERE field1 = 10”;
}
else
{
[custom_where] = “WHERE field2 = 80”;
}

sc_select_where(add) = [custom_where];

[search_was_done] is assigned a value in the onApplicationInt of 0.
You then give it a new value in the search event onValidate of 1.

hi,
onScriptInt it is executed every time the grid opens, even after a search, therefore it would always be added, if you change the variable value [custom_where] =1 after the search, when you return to the application in the same “session” it always remembers the filter set by the search.
i have a I have a dashboard where I would like to have an initial filter (last 7 day) and then be able to perform searches that exclude the initial filter (last 15 day)

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

From what you asked you want to do the following:

  1. When the application loads there is a initial filter.
  2. When the search is done the filter is updated.

My answer accomplishes both of those tasks.

From your reply it looks like the above quote is not what you want to have happen.
From what I can tell you want the following to happen:

  1. You want a initial filter that will always be in place on the main grid.
  2. During the search it self you want it to ignore the initial filter (7 days) and perform the search on a new filter (the 15 days one) while not changing the filter on the grid.

hi,
as I said I don’t want to add a clause, but completely remove the initial one from the table.
if I do as you wrote that macro sc_select_where(add) adds to where it does not replace.

Hi,

I assume then you didn’t read the full post I made. I specifically addressed this issue:

There you can see me saying to remove your current where clause and add it in the onScriptInt event with a if statement that checks whether or not a search has been done.

This way it will either use the one where clause or the other.