Hi,
Background: We had a ultragrid to show a list of records, all columns are enabled AllowFilter. There is a column in Date type, we want to control its filter conditions in a rule, but not by its default. We just added the compared value as a new FilterCondition by below code:
FilterConditionsCollection filters = mGrid.DisplayLayout.Bands[0].ColumnFilters[col].FilterConditions; if (mFilteringNonBlanksColumns.Contains(col.Key) && !string.IsNullOrEmpty(colValue)) { if (col.DataType == typeof(DateTime)) { filters.Add(new FilterCondition(FilterComparisionOperator.Equals, cellDate)); } else { filters.Add(new FilterCondition(FilterComparisionOperator.Equals, colValue)); } }
If the column is non-date column, it works well. I mean, the new added condition is CHECKED in the filter dropdown list, but, if it's a date column, it won't be checked, though it really filtered out the corresponding rows.
Hope it is clear for you understanding.
Question: What should I do to realize adding a new FilterCondition to date column, and make sure it's checked in the filter dropdown list as well?
NOTE: In your library, you use a type DateHierarchyFilterOperand to be the filter operand by default, and the type is private. Then I just created our own filteroperand like it, but, it would make all the filter conditions unchecked in the filter dropdown list.
Thanks
Daniel Chen
Hi Daniel,
The dropdown for the FilterUIProvider will only check a year in response to a FilterCondition of type DateHierarchyFilterOperand. As you pointed out, this class is internal. So there's currently no way for you to do what you are trying to achieve.
This seems to be something of an oversight on our part and I think it's something we need to look into further.
I have opened a private case for you so that I can link it to an internal development issue. This way you will be notified automatically when the dev issue is updated. The case number is CAS-152021-G4M8X3. You will see it here: https://www.infragistics.com/my-account/support-activity
Let me know if you have any questions regarding this matter.
Hi Mike,
The version we are running now is 12.1.20121.2024, could you provide the future solution base on this? The best way is to inherit and override some existing class of this version, otherwise, the upgrading would bring lots of stuffs to us.
That version is retired. There will be no more updates to 12.1. So any potential solution would only be available in the latest supported versions.
If you are looking for a workaround in the older version, then there is only one possible way to do it and that is to use reflection to create an instance of the DateHierarchyFilterOperand. So that would require that your application have permissions for reflection.
I am attaching a small sample project demonstrating this technique. The sample include a static utilities class called DateHierarchyFilterOperandUtils. Basically, you call the GetDateHierarchyFilterOperand method on this class and it uses reflection to create a DateHierarchyFilterOperand and return it to you and you can then use that instance as the operand in a filter condition.