Hello,
I have 2 questions regarding filters:
1. How can I get rid of the part highlighted in the attached filter.png file?
2. How does "Today" filter work? When i select it all records are filtered out even if I have some with today's date.
Thanks
Nick,
Thank you for suggested solution but I use custom CellValuePresenter style for fields so I can't really use Editor style. Or I will need to re-template XamDateTimeEditor. Is there other solution which will allow me to use my custom styles for CellValuePresenter.
EDIT: I just realized that I can do formatting in my custom template for CellValuePresenter so it keeps data record value as DateTime and filter works as expected. Will stick with this implementation for now.
Thank you for the modified sample and the code snippet.
Yes, when you want to modify the menu items list, you use the RecordFilterDropDownPopulating, like you did in your code snippet or modified version of it, for example:
private void xamDataGrid1_RecordFilterDropDownPopulating(object sender, Infragistics.Windows.DataPresenter.Events.RecordFilterDropDownPopulatingEventArgs e) { if (e.Field.Name == "Date") { var filterList = new List<FieldMenuDataItem>(); filterList.Add(e.MenuItems[0]); filterList.Add(e.MenuItems[1]); e.MenuItems.Clear(); e.MenuItems.Add(filterList[0]); e.MenuItems.Add(filterList[1]); } }
e.MenuItems.Clear();
e.MenuItems.Add(filterList[0]); e.MenuItems.Add(filterList[1]); } }
For your second question, I would recommend using XamDateTimeEditor and its format property for example:
<igDP:Field Name="Date"> <igDP:Field.Settings> <igDP:FieldSettings EditorType="{x:Type igEditors:XamDateTimeEditor}" EditAsType="{x:Type system:DateTime}"> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamDateTimeEditor}" > <Setter Property="Format" Value=" yyyy/MM/dd HH:mm:ss"/> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field>
I have modified the sample, please find it as an attached file.Additionally if you want to change the format depending on a different conditions, you can use a converter to return bool for example and apply different setters.
As for Date filter issue - I've altered you sample to reproduce it. As you can see I'm using custom converter to format date. Initially I thought that it is used just to display underlying data and filter functionality will use original value (which is of DateTime type) but it seems like it's not the case. What are other alternatives I can use? I prefer not having custom CellValuePresenter template as I ususally have 10k rows in a grid and performance is very important.
Hello Nick,
Please take a look at filter_expected.png. This is how I want it to be. I was able to achieve it by hooking to RecordFilterDropDownPopulating event and then using this code:
private void OnRecordFilterDropDownPopulating(object sender, RecordFilterDropDownPopulatingEventArgs e) { if (e.Field.Tag != null && e.Field.Tag.Equals(RemoveTreeviewFromFilter)) { var menuItem = e.MenuItems.FirstOrDefault(mi => mi.Header is RecordFilterTreeControl); if (menuItem != null) { var index = e.MenuItems.IndexOf(menuItem); e.MenuItems.RemoveAt(index); if (index > 0 && e.MenuItems[index - 1].IsSeparator) { e.MenuItems.RemoveAt(index - 1); } } } }
Is there better way of doing this?
Thank you for the image you have sent.
Can you provide some additional information about your scenario. You want to keep the ExcelStyle filtering, but remove the SearchBox and the items?Is FilterOperandUIType="TextBox" applicable to your scenario? You can find an attached project with example of this.
In your application, where you use "Today" filter, do you have additional styles or retemplating? I have added also a Date column in the example, please run and test it with the "Today" filter.
Looking forward to your reply.