Answered by:
PreProcessQuery filters not effected on Grid

Question
-
I created a query and put some filters in the preprocess event. I then added this query to an Existing screen under a tab. The code runs fine, and I can break in the event and I see all the filters happering there, but all results are returned to the grid, igoring the filters. I used query.Where(x => x.IsActive == true) to filter. Anyone know what is going on here?
There is always a way. You just have to find it.Sunday, September 4, 2011 7:27 AM
Answers
-
Thank you all for your suggestions. I finally got it to work: the problem was in the way I was composing the query. I had
query.Where(x => x.IsActive == true);
but it should be
query = query.Where(x => x.IsActive == true);
There is always a way. You just have to find it.- Marked as answer by TakalaneSesame Sunday, September 4, 2011 12:55 PM
Sunday, September 4, 2011 12:55 PM
All replies
-
Hi,
It sounds like you are doing it correctly, but maybe there are 2 queries on your viewmodel (lefthand side of the screen), and the correctly one (which gives the breakpoint) is not refering to the your grid? You can see the properties of the grid in the property windo (when pressing F4 ), there you can see to which query the grid is bound.
paul.
paul van bladelSunday, September 4, 2011 8:38 AM -
If I understand well you:
1. Create Query1 with filter
2. Add Query1_PreprocessQuery for this Query1
If this is right, you need to create Screen for this Query1 to get what you want. Try it.
Best regards
Spaso Lazarevic
- Edited by Spaso Lazarevic Sunday, September 4, 2011 8:55 AM
- Proposed as answer by Spaso Lazarevic Sunday, September 4, 2011 9:20 AM
Sunday, September 4, 2011 8:55 AM -
Indeed Spaso,
The easiest thing to do is that on your search screen, you simply delete the current grid.
Then, you drag and drop from the viewmodel (lefthand site) on your screen the query1 on the screen.
Good luck
paul van bladel- Edited by Paul Van Bladel Sunday, September 4, 2011 9:14 AM
Sunday, September 4, 2011 9:13 AM -
Or Takalane,
if you have Search screen already created you can use QuerySource to use you Query1 (First Select Entity from Left hand side and choose Query Source):
The same stands if you have EditibleGrid (or any), you need to use Query Source for your qery (not "Entity All" but your query)
Hope this help
Spaso Lazarevic
- Edited by Spaso Lazarevic Sunday, September 4, 2011 9:35 AM
- Proposed as answer by Spaso Lazarevic Sunday, September 4, 2011 9:43 AM
Sunday, September 4, 2011 9:31 AM -
Thank you all for your suggestions. I finally got it to work: the problem was in the way I was composing the query. I had
query.Where(x => x.IsActive == true);
but it should be
query = query.Where(x => x.IsActive == true);
There is always a way. You just have to find it.- Marked as answer by TakalaneSesame Sunday, September 4, 2011 12:55 PM
Sunday, September 4, 2011 12:55 PM -
Of course it should.
You sholud show us the whole method Takalane. From sign of method you can see that it need to return ref query.
Best regards
Sunday, September 4, 2011 4:37 PM