This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I've starting experimenting with the DataGrid filtering feature as described in Jason's blog post ("New: WPF DataGrid filtering"), and find it very promising. However, I have run into a an of issue that probably has to do with the way we set up our DataGrid columns. The properties we bind to are often not conventional CLR properties, but are instead specified through the ICustomTypeDescriptor interface. For consistency we always have a PropertyDescriptor for any property, since that is what ICustomTypeDescriptor supplies, and we can easily make a PropertyDescriptor to wrap any other property as well. When setting up DataGridColumns we always set the DisplayMemberBinding, and either the DisplayTemplate or DisplayTemplateSelector property. However, in this scenario we find that when we enable the filter popup (as in IsColumnHeaderFilterVisible="True") the popup always treats the column as a string, rather than the true type (e.g., int). As an experiment I tried setting the DataGridColumn.PropertyName and found that it made no difference. However, when I set the DataGridColumn.PropertyName and do not set DataGridColumn.DisplayMemberBinding then the popup targets the correct property type (at least for ints, which I tested). In this case it works correctly even if the property specified only through the ICustomTypeDescriptor interface (no conventional CLR wrapper). So it seems that setting the DisplayMemberBinding interferes with getting the correct type for filtering. I believe I had been advised by Jason in response to a previous forum post that I should set the DisplayMemberBinding even if I supply a DataTemplate, because other features depend on it. I am hoping there is a way we can set the DisplayMemberBinding and still get the columns correctly typed for filtering. We could easily directly specify the property type for the column if it could help. Thanks Peter |
|
|
Hi Peter, The next nightly build will have a new property on DataGridColumn called PropertyType. You can set this to the type that you want to be used for the filtering. I've gone with this approach as I couldn't find a way to get the properties from an ICustomTypeDescriptor without an instance - and the column headers that set up the filtering don't have access to an instance, so need to entirely use types and reflection. Hope that helps. -Jason Fauchelle |
|
|
Hi Jason, Thanks for adding this feature, which looks like it should solve my problem. However, I have downloaded the latest nightly builds for 1/6/2016 and 1/7/2016 and have not found the change you described. Furthermore, I see the date on the Mindscape.WpfElements.dll and WpfControlsSource.zip is 1/1/2016, so it looks like the nightly build has not been updated since 1/1/2016. Looking forward to trying this out. Thanks Peter |
|
|
Hi Peter, Sorry about that. We should have the nightly builds working again by next week. -Jason Fauchelle |
|
|
Hi Jason, I downloaded the Jan 18 nightly build and found it does have the change you described. It works very well--thank you! What I found works best for me is that if the property type is "primitive" (IsPrimative is true), DateTime, or string then I set column.PropertyType to the actual type so that I get the Mindscape editor defined for the type. Otherwise I set the column.PropertyType to typeof(string) to just get string filtering for my custom data types (which rely on DataTemplate for display and override ToString()). One question--are there any other data types (other than primatives, DateTime, and string) that Mindscape provides editors for that I might want to take advantage of? Thanks Peter |
|
|
Hi Peter, Great to hear that the new property works well for you. You have listed all the filter editors that we provide. -Jason Fauchelle |
|