Hi,
I am starting to believe that even manual filtering is not possible with your grid when using it with anything but the XPO.
And that's sad.
I have my ASPxGridView with an ObjectDataSource and have filtering enabled.
When the user selects some value from any filter combobox or from the filterrow, how can I have access to the Filter Criteria/Expression?
My idea is to catch the BeforePerformDataSelect event to pass the Grid's filter to my class before it performs the select command.
How can I do this?
Luis
Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Hi Luis;
If this answer isn't satisfactory for you, please let me know.
Thanks
Kate.
Hi,
Well, I know that there is a FilterExpression property.
The question is to know where can I access its value when the user makes a filter (either using the filter row or using the column's filter combo box).
I need to access this value because I need to pass the correct where clause to my select method and I have no way to do this.
Thanks.
Hi Luis;
I believe, you can use the e.Criteria property of the ProcessColumnAutoFilter event.
If this solution still doesn't meet your requirements, please let me know.
Thanks
Kate.
Hi Kate,
Well although catching that event is not bad it still has some problems.
1) It doesn’t work for the filter dropdown combo boxes.
2) It just allows me to get the criteria for one column at a time. If the user sets a filter for a second column I lose the criteria of the first one.
I saw that if the user sets the filter in the filter row editors, in the BeforePerformDataSelect event I can get the FilterExpression value for all columns.
The problem with this beside the one stated in 1), is that it’s the filter text already created, not the criteria class that allows me to fine tune the filter text I pass to my DB.
In this case ASPxGridView surrounds fieldnames with [ ] and FireBird doesn’t support them.
So I still have the same problem.
The ideal solution was to have a FilterCriteria property in the BeforePerformDataSelect event. From this one I would pass the correct WhereClause to my database query.
It would be a nice 8.3 enhancement.
The problem I see with ASPxGridView is the fact that it’s very restricted to XPO.
Let me state the reason I can’t use XPO:
1) I don’t want to. In my case I have s subscription so XPO its included but otherwise I would have to buy it to get APSxGridView in its full power.
2) I use FireBird and need MembershipProvider, ProfileProvider, etc…
3) I already have my Business Logic classes created and don’t want to put them in the garbage.
4) I have to use Stored Procedures and Views, because the database I will have to use for my ASP.NET app is the same the Desktop version uses and is going to be shared by the two app models.
I know other customers have the same issues and it would not be hard for you to extend the grid to have some extra functionality.
I don’t want the grid to do all the things automatically like it does with XPO. Working with events is good for me. I already have to do that with the VCL version.
Please think about this.
Hi Luis;
I'm sorry. but I can't see a problem with parsing the current filter expression in the BeforePerformDataSelect event handler:
protected void ASPxGridView1_BeforePerformDataSelect(object sender, EventArgs e) { string query = ((ASPxGridView)sender).FilterExpression; CriteriaOperator crOp = CriteriaOperator.Parse(query); }
However, if you need to filter the grid by multiple fields manually, you can meet the problem with auto filtration. When the AutoFilterRow editor loses focus, the ASPxGridView will start the filtering process. I'm sorry, but it is impossible to change this behavior. A solution is to add editors above the grid and filter the ASPxGridView programmatically using its AutoFilterByColumn method.
Thanks
Kate.
Hi Kate,
Thanks for your help.
I was missing the use of the CriteriaOperator class.
Bu I still have one problem. When the user selects some value from some column's filter dropdown combobox, I have no way to access that value in order to pass it to my select method, or do I?
Thanks.
Hi Luis;
If you prefer to use the BeforePerformDataSelect, you can get access to this value as follows:
string fExpr = ((ASPxGridView)sender).FilterExpression; if (fExpr != "") { BinaryOperator crOp = CriteriaOperator.Parse(fExpr) as BinaryOperator; object val = (crOp.RightOperand as OperandValue).Value; }
I've attached a short screencast that illustrates my answer.
Thanks
Kate.
Hi Kate,
Thanks for your help. When you say: "If you prefer to use the BeforePerformDataSelect,…" do you mean that I have another option?
Sorry if I ask some stupid question, I am a beginner in (ASP).NET (moving away from Delphi) so I will make many mistakes.
I will check your solution and get back to you with the results.
Thanks.
Luis.
Hi again,
I saw your screen cast and what you did is what I have, but in my case the FilterExpression is always empty.
protected void gvNews_BeforePerformDataSelect(object sender, EventArgs e) { string query = ((ASPxGridView)sender).FilterExpression; // here query is always empty... // in your screen cast I saw isn't. I will create a screencast here and upload it so you can see. CriteriaOperator crOp = CriteriaOperator.Parse(query); }
Hi Luis;
I'm afraid, I cannot fix this issue without your sample illustrating it . If t is possible, please provide this sample.
Thanks
Kate.
Hi Kate,
I found the problem. It's my fault.
In the HeaderFilterFillItems event I was using the e.AddValue() incorrectly.
It's now working fine. Thanks again and sorry for the time lost with my mistake.
Thanks.
Luis
Hi Luis;
I'm happy to hear that the issue is solved.
If you will have another questions, please don't hesitate to ask them.
Thanks
Kate.