[DevExpress Support Team: CLONED FROM K18434: How to convert the CriteriaOperator to the corresponding filter string in order to use it for building SQL queries or for filtering the DataView]
Hi,
really nice function thanks for that one i was searching for this!
But now im facing another Problem. Some of the columns in my Grid has the type int32 or datetime. As you know i cant use the LIKE Operator fot These columns. Is there any way to solve this Problem whithout cast the columns to another data type in my data source?
Best regards
Is there any way to solve the problem with Int32 or DateTime columns when using the approach described in the K18434 article?
Answers approved by DevExpress Support
The problem was solved by using strongly typed columns.
Hi Janis,
The CriteriaToWhereClauseHelper class simply converts the CriteriaOpeator passed to it into a corresponding expression. If there is an unsupported operation, such as applying the LIKE operator to a numeric column, this issue should be handled at the higher level.
If you describe how you build the CriteiraOperator, I can provide you with an appropriate solution.
Hi Uriah,
well i have a ColumnFilterChange event in which i want to use the DataView to be the datasource of a Chart. So i use the activeFilterCriteria of the GridView:
and use it as the RowFilter in the DataView:
string strFilter = DevExpress.Data.Filtering.CriteriaToWhereClauseHelper.GetDataSetWhere(op); DataView oDataView = (DataView)oView.DataSource; oDataView.RowFilter = strFilter;
After that i simpy assign the DataView to the chart:
So my Problem is when i typed any filter in the Grid into a column with a datatype like int32 the Funktion GetDataSetWhere creates a string like "([Year] like '201%')". So i cant apply that string to the RowFilter property because the Year column is actually an int and wont allow the LIKE Operator.
Hi Janis,
Is it a strict requirement to allow users to use the "LIKE" operator against a numeric column? If not, I suggest disabling the auto filter row cell for this column and allowing users to choose an appropriate value via the column filter popup. Is this solution acceptable?
Hello Uriah,
thanks for the reply!
This is a good solution in my case but im facing another problem now. My columns can contain empty values. When im selecting "Blanks" in the column filter popup the filter string which is created via GetDataSetWhere looks like:
(([Activation_Date]) is null or (len([Activation_Date]) = 0))
The len() function Needs a string and won't allow dates (i dont know if thats work for ints. My int columns never contains empty values).
Do you have any suggestions how to solve this?
Hello Janis,
Is the Activation_Date property of the datasource item of the String type? I suggest that you make this property of the nullable type - DateTime? . This way, you will be able to assign null values to this property. At the same time, users will be able to choose the Is null operator in the filter editor, as shown in the screenshot. The Is null operator is applicable for DateTime columns.
Hi Uriah,
thanks for the answer that works fine for me.
Hi Janis,
I am happy to hear that the problem is solved. Please do not hesitate to contact us again in the future.