Hello,
i use a XamDataGrid containing a ComboBoxField, AllowRecordFiltering = true. I want the filter applies to the resolved DisplayMemberPath, and therefore the Filteroperators be based on type string.
Please see the attached example.
Greetings
iA. Kits
Hello joerg_nuemann,
Thank you for contacting Infragistics. I've ran your sample and I am unsure what you wish for me to test, everything appears to be filtering correctly. However, based on my understanding of your requirement you wish to have the "T2" string column filter in records based on exactly what is typed in the filter cell?
In order to match the records with the exact filter I recommend setting the field's settings FilterOperatorDefaultValue to ComparisonOperator.Equals.
eg.
private void XamDataGrid_FieldLayoutInitialized(object sender, Infragistics.Windows.DataPresenter.Events.FieldLayoutInitializedEventArgs e) { e.FieldLayout.FieldSettings.FilterOperatorDefaultValue = Infragistics.Windows.Controls.ComparisonOperator.Equals; }
Let me know if you have any questions.
Hellp Michael,
thanks for your reply.
No, i want the filter operators of C1 be the same as of T2. Please see the attached screenshot.
Hello Michael,
i want this "custom" filter operator list for every XamComboEditor i use. (The "custom" list, is the operators for "type of string" - see T2.)
I dont want configure this manually for every single field. I dont want a xaml base FieldSetting, which i weould have to inherit (BasedOn) into every single manual FieldSetting i use.
Can you please offer me a way to configure this globally. (Like, is there any grid event for the operator list initialized i can hook on, check if its XamComboEditorField, and customize the operator list?)
Hello joerg,
Thank you for your reply. There is no built-in way that I am aware of to tell any field of any type to load filter items based on string without changing the Field's DataType property. The following example code will give you the flexibility you seek when attempting to modify the operator list.
var layout = this.grid.FieldLayouts[0] as FieldLayout; foreach (Field item in layout.Fields) { if (item.DataType == typeof(ComboBoxField)) { item.Settings.FilterOperatorDropDownItems = ComparisonOperatorFlags.StartsWith | ComparisonOperatorFlags.EndsWith; } }
I started a discussion with my team to figure out a more viable approach. Let me know if you have any questions.
Please disregard my previous email. If you set the EditAsType property for each ComboBoxField, then you can achieve your requirement without having to manually add items.
eg. xaml implementation
xmlns:sys="clr-namespace:System;assembly=mscorlib" <ig:ComboBoxField Name="C1" Label="C1" Width="150" EditAsType="{x:Type sys:String}" ItemsSource="{Binding Value.ItemComboList, Source={StaticResource proxy}}" ValuePath="ID" DisplayMemberPath="Name" />
xmlns:sys="clr-namespace:System;assembly=mscorlib"
<ig:ComboBoxField Name="C1" Label="C1" Width="150" EditAsType="{x:Type sys:String}" ItemsSource="{Binding Value.ItemComboList, Source={StaticResource proxy}}" ValuePath="ID" DisplayMemberPath="Name" />
Let me know if this addresses your issue or have any additional quesitons.
thanks for your reply. I combined both of your ideas, so i can set the EditAsType programmatically and globally.
grid.FieldLayoutInitialized += OnFieldLayoutInitialized; private static void OnFieldLayoutInitialized(object sender, FieldLayoutInitializedEventArgs e) { foreach (Field field in e.FieldLayout.Fields) if (field.EditorTypeResolved == typeof(Infragistics.Windows.Editors.XamComboEditor) || field.Settings.EditorStyle?.TargetType == typeof(Infragistics.Windows.Editors.XamComboEditor)) field.Settings.EditAsType = typeof(string); }
private static void OnFieldLayoutInitialized(object sender, FieldLayoutInitializedEventArgs e) { foreach (Field field in e.FieldLayout.Fields) if (field.EditorTypeResolved == typeof(Infragistics.Windows.Editors.XamComboEditor) || field.Settings.EditorStyle?.TargetType == typeof(Infragistics.Windows.Editors.XamComboEditor)) field.Settings.EditAsType = typeof(string); }
PS: Though i wonder why this is not the default..
Hello Kits,
I am glad you got this working.
The EditAsType for a ComboBox field must be explicitly set because the DataType is ComboBox. The EditAsType would only need to be initialized if the DataType of the Field differs from how the value should be interpretted.
Let me know if you havea any additional questions.
the EditAsType has other side-effects, so i "cant" use it.
Hello Joerg,
Thank you for following up. There aren't any side effects that we are aware of. Please list what side effects you are seeing and clarify how to reproduce them so I can propery investigate this further. Let me know if you have any questions regarding this matter.