This project has moved and is read-only. For the latest updates, please go here.

DataGridFilterColumn.Template Questions

Aug 7, 2013 at 6:26 PM
Edited Aug 8, 2013 at 3:54 PM
a) is there a way to be able to provide all of the Distinct values for a column to its DataGridFilterColumn.Template? I'd like my "FilterWithPopupControl" actually be a combobox that shows all of the unique values, so that upon selection, I can provide a filter that matches on that. Or, to augment this idea further, how can we pass any of the DataGridColumn's information to the FilterWithPopupControl, like say if we wanted column header text to appear somewhere in the popup.

b) how would you handle "overall data" level filtering in addition to the column filtering provided by the DataGridFilterColumn.Template? For example, I say I have an attribute on my Model item that is "IsNew", but there isn't a matching column for it in the data grid. So I'd like to be able to filter on a column via the FilterWithPopupControl, but ALSO, filter on from an external control, (say a checkbox) for the IsNew property.

Without the DataGridFilterColumn.Template, I would add filters on my ListCollectionViewSource, but how do i use these two approaches in concert?

c) is a Group By selector possible?

thanks
Aug 9, 2013 at 11:17 AM
a) The DataGridFilterColumnControl has a "Values" property, that should do the job. It's on the same object as the "Filter" property.
        /// <summary>
        /// Returns all distinct visible (filtered) values of this column as string. 
        /// This can be used to e.g. feed the ItemsSource of an AutoCompleteBox to give a hint to the user what to enter.
        /// </summary>
        public IEnumerable<string> Values
        {
            get
            {
                return InternalValues().Distinct();
            }
        }
b) Maybe you can just nest two ListCollectionViewSource, the first doing the global filtering and being the source for the second, doing the column filtering.
c) How to: Group, Sort, and Filter Data in the DataGrid Control
Aug 24, 2014 at 6:04 AM
tomenglert wrote:
a) The DataGridFilterColumnControl has a "Values" property, that should do the job. It's on the same object as the "Filter" property.
        /// <summary>
        /// Returns all distinct visible (filtered) values of this column as string. 
        /// This can be used to e.g. feed the ItemsSource of an AutoCompleteBox to give a hint to the user what to enter.
        /// </summary>
        public IEnumerable<string> Values
        {
            get
            {
                return InternalValues().Distinct();
            }
        }
hrm.. the Values property only shows the currently visible set of options. I would like to display the entire set of values so I can present the user with the ability to select additional filter criteria (think of excel's autofilter dropdown... )

Any way to do this?
Aug 24, 2014 at 6:23 PM
Yes, InternalValues() retrieves from DataGrid.Items, which are the filtered items.
You could do the same referring to DataGrid.ItemsSource, since you will know what your items source is about.
If it's helpful I could add this, it would work if ItemsSource is an IList, however I'm not sure if that would follow changes of ItemsSource properly.
Aug 24, 2014 at 7:05 PM
I have added a "SourceValues" property. Can you download the latest source and test if that works and fit's your needs?
Aug 27, 2014 at 4:38 AM
It works perfectly! Thanks so much.
Oct 29, 2015 at 8:40 AM
Hi!

I am trying to find out how to use the SourceValues property, can anyone provide an example?

//Peter
Feb 26, 2016 at 6:34 AM
There is now a basic sample in the sample app:
<ControlTemplate x:Key="ComboboxFilter">
<Grid>
  <Grid>
    <Control Style="{DynamicResource {x:Static dgx:DataGridFilter.IconStyleKey}}"/>
    <ComboBox x:Name="ComboBox" Text="{Binding Path=Filter, UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding SourceValues}" IsEditable="True" />
  </Grid>
</Grid>
Marked as answer by tomenglert on 10/5/2016 at 7:00 AM