Is it possible to replace the textual representation of a filter shown on the filter panel with the text from the filter dialog? The last one is more readable and less technical and it would improve the useability.
I've already a custom grid derived from GridView. So I think there must be an easy way to do this.
Hope for your help!
Thanks in advance
To accomplish this task, you can use localizer or satellites assemblies (The collection of localized DevExpress assemblies).
For example :
Public Sub New()
DevExpress.XtraEditors.Controls.Localizer.Active = New MyLoc()
Public Class MyLoc
Public Overrides Function GetLocalizedString(ByVal id As DevExpress.XtraEditors.Controls.StringId) As String
If id Is DevExpress.XtraEditors.Controls.StringId.FilterGroupNotAnd Then
First I would like to thank you for very fast response.
But I think there is a misunderstanding. Let me take an example:
I create a filter in the grid: column A has to contain "xxx".
In the filter dialog I have the wonderful and easy readable textual representation:
"[Column A] contains xxx".
But the filter panel shows:
"[Column A] Like '%xxx%'"
With the solution you posted before I could replace the "Like" with "contains". But there are still the quotation marks and the percent signs. And that’s only a very simple example. How about "is between" and "is blank"? It’s not only a question of replacing certain words. The whole filter criteria are differently represented.
I’m looking forward to your answer.
I’m sorry to say, but I think you didn't get what I want to do.
I already know that I can change the text on the filter panel by handling the ColumnView.CustomFilterDisplayText event. What I do not know is how I get the text, which the filter editor displays. As I already said on my last post, the filter editor has a little different way to represent the filter criteria. It shows "[Column A] contains xxx" instead of [Column A] Like '%xxx%'. The code for converting a filter to this nice textual representation is already somewhere inside the grid. The only thing I need is to know, how I get this without to create it step by step on my own.
I'm looking forward to your response
thanks in advance
Hi Dirk ,
Unfortunately, there is no public method to get this information.
Generally, a filter is a tree-like structure of conditions grouped with AND/OR operators. The root node in this structure is the FilterControl.FilterCriteria property. I advise that you review the implementation of the CriteriaToTreeProcessor class in DevExpress.Data\Filtering\FilterControlModel.cs (the DevExpress.Data assembly). It will give you an idea on how to process individual conditions of a CriteriaOperator object.
DevExpress.Data.Filtering.Helpers.CriteriaToTreeProcessor.GetTree(new DevExpress.XtraEditors.Filtering.FilterControlNodesFactory(), Criteria, null);
//where Criteria is DevExpress.Data.Filtering.CriteriaOperator
I'm gone through some coding and found a solution. At the moment it’s not complete because it’s only showing the first filter criterion but it shows how it works. The next step is to go through the tree-like structure of conditions to get all filters and combine them in sequence with the appropriate brackets
private void segoniGridView1_CustomFilterDisplayText(object sender, DevExpress.XtraEditors.Controls.ConvertEditValueEventArgs e)
DevExpress.XtraEditors.Filtering.Node newRootNode = DevExpress.XtraEditors.Filtering.CriteriaToTreeProcessor.GetTree(this.segoniGridView1.ActiveFilterCriteria, null);
if (newRootNode != null)
FilterControl fs = new FilterControl();
fs.SourceControl = this.segoniGridControl1;
DevExpress.XtraEditors.Filtering.FilterControlLabelInfo li = new DevExpress.XtraEditors.Filtering.FilterControlLabelInfo(newRootNode);
e.Value = li.Text.Replace("@-","");
e.Handled = true;
Do you have any suggestions to simplify the solution? The most disturbing part for me is that I’m dared to create an instance of FilterControl.
Thanks for your assistance
ps: in my version 8.2 the CriteriaToTreeProcessor is not in DevExpress.Data but in DevExpress.XtraEditors
Is your intention to post an answer to your own question?
- If so, then proceed.
- If you simply wanted to post additional information, ask for further clarification, or to just say "Thanks!", please click Leave a Comment.
- If you wish to edit your original question, please use the Edit button in the Toolbox at the top right corner of that entry.