'Declaration Public ReadOnly Property FieldFilters As ObservableCollection(Of FieldChooserFilter)
public ObservableCollection<FieldChooserFilter> FieldFilters {get;}
FieldFilters property lets you specify groups of fields. Each field layout's fields can be broken up into subgroups. For example, in a Customer/Orders hierarchical data source, you can group Orders' field layout's fields into "Date Fields", "Adress Fields", "Phone/Fax Fields" etc... The field-layout selector will display these subgroups under the applicable field-layout. The end user then can select, for example, "Date Fields" entry under "Orders" entry in the field-layout selector to show only the date fields of the Orders field-layout.
Imports Infragistics.Windows Imports Infragistics.Windows.Controls Imports Infragistics.Windows.Editors Imports Infragistics.Windows.DataPresenter Imports Infragistics.Windows.DataPresenter.Events Private Sub Dp_FieldChooserOpening(ByVal sender As Object, ByVal e As FieldChooserOpeningEventArgs) Dim fieldChooser As FieldChooser = e.FieldChooser ' Only add field filters if we haven't already added previously. FieldChooserOpening ' gets raised every time the field chooser is displayed by the data presenter. ' If fieldChooser.FieldFilters.Count = 0 Then ' Create a FieldChooserFilter that creates a group of address fields. Dim addressFieldsFilter As FieldChooserFilter = New FieldChooserFilter() addressFieldsFilter.Description = "Address Fields" addressFieldsFilter.ToolTip = "Displays address related fields" addressFieldsFilter.Filter = New Predicate(Of Field)(AddressOf IsAddressField) ' Create a FieldChooserFilter that creates a group of date fields. Dim dateFieldsFilter As FieldChooserFilter = New FieldChooserFilter() dateFieldsFilter.Description = "Date Fields" dateFieldsFilter.ToolTip = "Displays date fields" dateFieldsFilter.Filter = New Predicate(Of Field)(AddressOf IsDateField) ' Add the above filters to the collection returned by the field chooser's ' FieldFilters property. fieldChooser.FieldFilters.Add(addressFieldsFilter) fieldChooser.FieldFilters.Add(dateFieldsFilter) End If End Sub Private Function IsAddressField(ByVal field As Field) As Boolean ' Create a list of fields that belong to this group. Dim addressFields As String() = _ { _ "Full_Name", _ "Address_Line1", _ "Address_Line2", _ "City", _ "State", _ "Zip", _ "Country" _ } Return Array.IndexOf(addressFields, field.Name) >= 0 End Function Public Function IsDateField(ByVal field As Field) As Boolean Return field.DataType Is GetType(DateTime) OrElse field.DataType Is GetType(Nullable(Of DateTime)) End Function
using Infragistics.Windows; using Infragistics.Windows.Controls; using Infragistics.Windows.Editors; using Infragistics.Windows.DataPresenter; using Infragistics.Windows.DataPresenter.Events; private void dp_FieldChooserOpening( object sender, FieldChooserOpeningEventArgs e ) { FieldChooser fieldChooser = e.FieldChooser; // Only add field filters if we haven't already added previously. FieldChooserOpening // gets raised every time the field chooser is displayed by the data presenter. // if ( fieldChooser.FieldFilters.Count == 0 ) { // Create a FieldChooserFilter that creates a group of address fields. FieldChooserFilter addressFieldsFilter = new FieldChooserFilter( ); addressFieldsFilter.Description = "Address Fields"; addressFieldsFilter.ToolTip = "Displays address related fields"; addressFieldsFilter.Filter = new Predicate<Field>( delegate( Field field ) { // Create a list of fields that belong to this group. string[] addressFields = new string[] { "Full_Name", "Address_Line1", "Address_Line2", "City", "State", "Zip", "Country" }; return Array.IndexOf( addressFields, field.Name ) >= 0; } ); // Create a FieldChooserFilter that creates a group of date fields. FieldChooserFilter dateFieldsFilter = new FieldChooserFilter( ); dateFieldsFilter.Description = "Date Fields"; dateFieldsFilter.ToolTip = "Displays date fields"; dateFieldsFilter.Filter = new Predicate<Field>( delegate( Field field ) { return field.DataType == typeof( DateTime ) || field.DataType == typeof( DateTime? ); } ); // Add the above filters to the collection returned by the field chooser's // FieldFilters property. fieldChooser.FieldFilters.Add( addressFieldsFilter ); fieldChooser.FieldFilters.Add( dateFieldsFilter ); } }
Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2