User (Old forums)MemberApril 24, 2008 at 3:03 pmPost count: 23064
I have 2 questions about filtering. I am looking at the SolidFoundation example that comes with the DataGrid. Perhaps I am just blind but I am wondering in that example how do you prevent certain columns from having the Filtering ability? I turned on Filtering in my app and all the columns are now filtering.
My second question is could someone show me how to do a filter in code? Basically the filtering is working the way I would like but I want the application when it starts up to be filtered in a certain way in a certain column. (In other words lets say the column was called “States” and lets say when I launch the app I only want to show all the rows that have “New York” in that filter….how would you do that in c# code?
Imported from legacy forums. Posted by David (had 1208 views)Xceed SupportMemberApril 24, 2008 at 3:38 pmPost count: 5658
The auto-filter drop down will appear when distinct values are calculated for a data-grid item property. That said, you can set the DefaultCalculateDistinctValues property of the DataGridCollectionViewSource to false (by defaul true) and explicitly set the CalculateDistinctValues property of each data-grid item property for which you want the auto-filtering to true.
If you are using the DataGridCollectionView in code, you will need to explicitly set the CalculateDistinctValues of the data-grid item properties for which you don’t want auto-filtering to false.
As for providing an inital filter:
DataGridCollectionView view = new DataGridCollectionView( App.Orders.DefaultView );
view.AutoFilterMode = AutoFilterMode.And;
view.AutoFilterValues[ “ShipCountry” ].Add( “Canada” );
this.OrdersGrid.ItemsSource = view;
Imported from legacy forums. Posted by Jenny [Xceed] (had 1707 views)User (Old forums)MemberApril 25, 2008 at 2:08 pmPost count: 23064
Thanks! That works great!
I tried doing a filter on a detail row…and I keep getting a exception.
new DataRelation(“Site_Contacts”, table_Site_ID.Columns[“ID”], table_Site_Contacts.Columns[“Site_ID”]));
new DataRelation(“Scheduler_To_Site_ID”, table_Site_ID.Columns[“ID”], table_Scheduler.Columns[“ID”] ));//table_Scheduler.Columns[“ID”]));
DataGridCollectionView dataGridCollectionView = new DataGridCollectionView(table_Site_ID.DefaultView);
“Scheduler_To_Site_ID”].AutoFilterMode = AutoFilterMode.And;
// the line below is the line that is throwing a exception (System.Windows.Markup.XamlParseException was unhandled)
dataGridControl_Site_ID.ItemsSource = dataGridCollectionView;
When I try to do a filter on the parent row with the same exact field type and similar code it works fine for the parent row. Any ideas on what is going on here?
Imported from legacy forums. Posted by David (had 554 views)Xceed SupportMemberApril 25, 2008 at 3:13 pmPost count: 5658
This is a normal behavior and by design: DetailDescriptions are used to configure the Details inside the grid. For each Detail, a DataGridCollectionView is created by the DataGridControl when the detail is expanded. Otherwise, the data related to those details is unaccessible. The Auto-Filtering feature is managed by the DataGridCollectionView and the AutoFilterValues[FieldName] Dictionnary must be initialized by the DataGridCollection with the field names in the Detail.
That is exactly the case in your scenario: you are attempting to access one of the field in a DataGridCollectionView’s DetailDescription before it is actually created. This is not currently supported. I’ll enter a feature request and we’ll keep you informed on this thread.
Imported from legacy forums. Posted by Chris [Xceed] (had 679 views)User (Old forums)MemberApril 25, 2008 at 3:38 pmPost count: 23064
Hmmmm well that makes more sense now….
Would this be added in 2.2? Or some version after would you know?
Imported from legacy forums. Posted by David (had 566 views)Xceed SupportMemberApril 25, 2008 at 4:01 pmPost count: 5658
At the moment, we can’t say if it will be implemented or not, neither in which version it would be. We’ll keep you informed as soon as we have further informations.
Imported from legacy forums. Posted by Chris [Xceed] (had 503 views)User (Old forums)MemberApril 29, 2008 at 12:58 pmPost count: 23064
This actually brings up another question….
I am wondering if you can use a DataTableDictionary like you can in the master column? (Basically can you make a combobox with a list of items the user can pick like you can when its the top parent)?
Imported from legacy forums. Posted by David (had 577 views)Xceed SupportMemberApril 29, 2008 at 1:14 pmPost count: 5658
Yes. You can activate auto-filtering in the details by setting the DataGridDetailDescription’s (defined in the DataGridCollectionView[Source]) AutoFilterMode property to And or Or.
Imported from legacy forums. Posted by Jenny [Xceed] (had 827 views)User (Old forums)MemberMay 9, 2008 at 10:13 amPost count: 23064
I think I have 1 more filtering question….
This thread was great about showing how to do a pre-defined filter before you load the grid up. But if the grid is already loaded up and I have a button that would have a few defined filters…how would I go about doing that? (So in other words the Datagrid us already filled with data…the user pushes a button that will add some filters to a certain column….how would you go about that in code?)
Imported from legacy forums. Posted by David (had 627 views)Xceed SupportMemberMay 9, 2008 at 3:14 pmPost count: 5658
For the master level, you can do exactly as in your previous post:
DataGridCollectionView dataGridCollectionView = grid.ItemsSource as DataGridCollecitonView (Get your DataGridCollectionView used as ItemsSource)
AutoFilterValues[“AutoFilteredField“].Add( FilterValue );
AutoFilterValues[“AutoFilteredField“].Add( FilterValue1 );
… (for all values required for this field)
AutoFilterValues[“AutoFilteredField2“].Add( FilterValue2 );
… (for all values required for this other field)
For the detail level, it is not yet supported as mentionned earlier.
Imported from legacy forums. Posted by Chris [Xceed] (had 1962 views)
- You must be logged in to reply to this topic.