display columns filter

Jun 30, 2009 at 2:42 PM
Edited Jun 30, 2009 at 2:43 PM

is this possible with the datagrid?


Jun 30, 2009 at 9:33 PM

Hi edderic,

Could you expand on what exactly you're looking to enable?  Do you want to filter which columns are in view? Or do you want to add a filter to your column to choose which data is displayed?


Jul 1, 2009 at 7:27 PM

RE:Do you want to filter which columns are in view?

Yes like infragristrics datagrid,janus datagrid etc...

Jul 1, 2009 at 9:26 PM

Ok, this should be relatively simple to do, depending on what kind of filter UI you're looking for.  The DataGridColumns have a Visibility property which can be set to Visible, Hidden, or Collapsed.  You can do something like provide a filter control somewhere in the app's UI which has a CheckBox for each column and bind that CheckBox's Checked state to the Visibility of the column.  Or you could hook up a ContextMenu for the DataGrid which allows the user to choose the visible columns.  I'm not familiar with the UI provided for this feature in the third party DataGrids (we have not looked at any third party controls for legal reasons), so I'm not sure what exactly you're trying to accomplish, but you should be able to build whatever UI you want and just bind it to the column Visibility to hide/show columns as desired.

Jul 1, 2009 at 10:19 PM

i think that you not understand me,i have a column "City" where i can filter to Like "Ab" etc...Or a column "Language" where i can filter to "Belgium" etc...



Jul 1, 2009 at 11:58 PM
Edited Jul 1, 2009 at 11:59 PM

I see - that was what I meant when I asked "Or do you want to add a filter to your column to choose which data is displayed?"

We do not have this ability built in to V1, but it should be fairly simple to implement.  The actual filtering can be handled by CollectionViewSource (CVS) and you just need to build the UI to call CVS's Filter event.  For an example of how to filter using CVS, see this MSDN article: http://msdn.microsoft.com/en-us/library/system.windows.data.collectionviewsource.filter(VS.85).aspx

A common format for the filter UI is to add a drop down menu in the column header which contains a list of values that the user can choose to filter by, similar to the UI you would find in Excel.  You can achieve this by retemplating the column header.