Giter Club home page Giter Club logo

datagridextensions's Introduction

Data Grid Extensions Build Status NuGet Status

Icon

Modular extensions for the WPF DataGrid control.

Code of Conduct

This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community. For more information see the .NET Foundation Code of Conduct.

.NET Foundation

This project is supported by the

.NET Foundation

Summary

This package contains useful extensions for the WPF DataGrid (System.Windows.Controls.DataGrid).

The current version supports the following features and behaviors:

  • Add filtering capabilities to the DataGrid
  • Apply the initial sorting
  • Disable another control while in editing mode
  • Provide additional column events
  • Start editing a cell with Ctrl+Enter
  • Provide an extended star-size column behavior
  • Methods to easily implement Excel-like copy/paste

The binaries are available as NuGet packages.

Read the Documentation about how to use these features. The API Documentation describes the global API for DGX.

Every feature is individually configurable.

This extension is

  • Easy to use
  • Easy to customize
  • Attaches to the existing DataGrid

Unlike many other free extensions this package does not introduce a new derived DataGrid class, limiting you a fixed set of features that you have to live with, but transparently attaches to the existing DataGrid, giving you the freedom to use exactly the feature you need, customizing them as you like, and combining them with other useful extensions.

Filtering is enabled by simply adding one attached property to your DataGrid:

<DataGrid ItemsSource="{Binding Items}" 
          dgx:DataGridFilter.IsAutoFilterEnabled="True"/>

You will get a simple but efficient text or boolean filter, depending on the column type: Sample1

Every part is easily customizable by providing simple styles or templates:

<DataGridTextColumn Header="Double/Custom" 
                    Binding="{Binding Probability, Mode=OneWay}" 
                    dgx:DataGridFilterColumn.Template="{StaticResource FilterWithPopup}"/>

By overriding the default template you can simply create individual filters:

Sample2

For a full functional demo run the sample app or see the ResX Resource Manager or Project Configuration Manager projects that use the filtering extensions.

Powered by   ReSharper    

Support this Project: Donate

datagridextensions's People

Contributors

grizoood avatar magauthier-liggo avatar mjuen avatar saracmert avatar tom-englert avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

datagridextensions's Issues

Filter transformation

Is there an out-of-the-box way to perform mapping of DataGrid values to filter values? I have a year column which I'm wishing to aggregate in the associated multi-choice filter as decades. I've taken a look at your sample MultipleChoiceFilter and DataGridFilterColumnControl but I can't see anything obvious.

It's easy for me to build this in a non-reusable fashion - populating the filters values explicitly - but it would be elegant if I could instead provide some sort of two-way mapping class.

Visible Items

Would be nice to be able to get all visible items as there is no good way to achieve that by default.

Paging

Would you please add an example of how to combine filtering and paging?

DOTNET 4.6.2

Does not work with DOTNET 4.6.2 - I will try download the code and rebuild with 4.6.2.

The Syste.Windows.Interactivity is the incompatible dll

Exception when clicking the SelectAll button on a extended-cell select grid

When clicking on the SelectAll button in top left corner of the datagrid then I get an exception.
XAML:
<DataGrid SelectionMode="Extended" SelectionUnit="Cell" dgx:DataGridFilter.IsAutoFilterEnabled="True" Name="testDataGrid"/>
TestData:

public class TestData
{
    public string Val1 { get; set; }
    public string Val2 { get; set; }
}

Code behind constructor:

testDataGrid.ItemsSource=new List<TestData>()
            {
                new TestData
                {
                    Val1="1",
                    Val2="test"
                },
                new TestData
                {
                    Val1="2",
                }
            };

Exception:

This exception was originally thrown at this call stack:
System.Windows.Controls.DataGridRow.OnIsSelectedChanged(object, System.Windows.DependencyPropertyChangedEventArgs)
System.Windows.DependencyObject.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs)
System.Windows.FrameworkElement.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs)
System.Windows.Controls.DataGridRow.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs)
System.Windows.DependencyObject.NotifyPropertyChange(System.Windows.DependencyPropertyChangedEventArgs)
System.Windows.DependencyObject.UpdateEffectiveValue(System.Windows.EntryIndex, System.Windows.DependencyProperty, System.Windows.PropertyMetadata, System.Windows.EffectiveValueEntry, ref System.Windows.EffectiveValueEntry, bool, bool, System.Windows.OperationType)
System.Windows.DependencyObject.SetValueCommon(System.Windows.DependencyProperty, object, System.Windows.PropertyMetadata, bool, bool, System.Windows.OperationType, bool)
System.Windows.DependencyObject.SetCurrentValueInternal(System.Windows.DependencyProperty, object)
System.Windows.Controls.Primitives.Selector.ItemSetIsSelected(System.Windows.Controls.ItemsControl.ItemInfo, bool)
System.Windows.Controls.Primitives.Selector.SelectionChanger.CreateDeltaSelectionChange(System.Collections.Generic.List<System.Windows.Controls.ItemsControl.ItemInfo>, System.Collections.Generic.List<System.Windows.Controls.ItemsControl.ItemInfo>)
...
[Call Stack Truncated]

If a filter is applied an no row is visible then no exception is thrown but all filters are reset and all rows are shown.

Using NotifyOnTargetUpdated=True causes StackOverflow Exception

Trying to build a filter component with a combobox with distinct values but when adding NotifyOnTargetUpdated=True I get a StackOverflow Exception.

<ComboBox ItemsSource="{Binding SourceValues, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=dgx:DataGridFilterColumnControl}, Mode=OneWay, UpdateSourceTrigger=PropertyChanged, NotifyOnTargetUpdated=True}"/>

Filter Binding Example

Can anyone provide an example showing how to bind the value of a filter control to a property on the view model? I'm trying to set default values for the filter.

Usage of GlobalFilter

Hi all,

I would like to implement a TextBox placed above the data grid where the user can search globally in the data grid.

I wonder if/how to use GlobalFilter for this.

I tried binding a Predicate to the GlobalFilter property. But the Predicate is evaluated only first time the data grid shows up.

Is there a way to apply the Predicate each time the text in the global search TextBox changes?

Or do I misunderstand the purpose of GlobalFilter?

Regards

Microsoft.Xaml.Behaviors.Wpf 1.0.30 - broken dependency

Hi Tom,

thanks for the library, it worked great so far.
The new WPF Behaviors library, Microsoft release 2 days ago, does not work with the Extension library.

VS is just complaining that a dependency was not met and is closing the application after that.

So reproducing is easy, just update it.

ComboBox via SelectableValues is not populated initially

Hi,

I just tried your wonderful extensions. However, when trying to use a ComboBox as seen in the example, the values aren't initially populated.

Only after I type something in the ComboBox it is populated via SelectableValues. Do you have any clue on what's going on or how I can debug this?

Exception when Binding to DataTable

Hello,

I get the following exception when I try to apply a filter:

System.NotSupportedException: Die angegebene Methode wird nicht unterstützt. bei System.Windows.Data.CollectionView.set_Filter(Predicate1 value)
bei System.Windows.Controls.ItemCollection.set_Filter(Predicate1 value) bei DataGridExtensions.DataGridFilterHost.EvaluateFilter() bei DataGridExtensions.DataGridFilterHost.<OnFilterChanged>b__19_0(Object _, EventArgs __) bei System.Windows.Threading.DispatcherTimer.FireTick(Object unused) bei System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) bei System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler) bei System.Windows.Threading.DispatcherOperation.InvokeImpl() bei System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state) bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) bei MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state) bei System.Windows.Threading.DispatcherOperation.Invoke() bei System.Windows.Threading.Dispatcher.ProcessQueue() bei System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) bei MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) bei MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) bei System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) bei System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler) bei System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs) bei MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) bei MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) bei System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) bei System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame) bei System.Windows.Application.RunDispatcher(Object ignore) bei System.Windows.Application.RunInternal(Window window) bei System.Windows.Application.Run(Window window) bei System.Windows.Application.Run() bei dewabit.App.Main() in C:\Users\Thomas\Desktop\dewabit\csharp\dewabit\App.xaml.cs:Zeile 34. bei System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() bei System.Threading.ThreadHelper.ThreadStart_Context(Object state) bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) bei System.Threading.ThreadHelper.ThreadStart()

In my DataGrid I am setting ItemsSource and DataContext to a DataTable.

Does anyone have an idea how to get this fixed?

Access the filtered collection from viewmodel

First of all thanks for this great project.

In my project datagrid is populated by an ObservableCollection in the viewmodel.

AFAIK the viewmodel doesn't know about filtering as filtering is performed in the view. Right?

Problem: the viewmodel needs to know which items of the ObservableCollection are currently displayed according to the filter.

Is there any way to access/create a subset of the viewmodel's ObservableCollection according to the filter?

Thanks in advance.

Issue with getting full library

Hello, I am having trouble getting the full DGX library to work. For example the following works with no problem:
dgx:DataGridFilter.GlobalFilter="{Binding GlobalFilter}"

But, when I try to use the next one, I get an error saying "The attachable property 'IsAutoFilterEnabled' was not found in type 'DataGridFilter.'
dgx:DataGridFilter.IsAutoFilterEnabled="True"
And similar errors for the following:
dgx:DataGridFilterColumn.Template="{StaticResource MultipleChoiceFilter}"
dgx:DataGridFilterColumn.IsFilterVisible="true"

Maybe I imported the nuget package incorrectly, am missing a dependency, or something completely else.
I am using it on a WPF application in VS2019, so I went to Manage Nuget Packages, found DataGridExtensions, installed it, and then even installed it through the Package Manager Console as such:
Install-Package DataGridExtensions -Version 2.5.1
Am I missing another step?

DataGridFilterColumnControl.SourceValues to be updated on DataGrid.ItemsSource CollectionChanged

Hi and thanks for this great project.

After experimenting a bit with this library, I figured out that the SourceValues of the DataGridFilterColumnControl class is not being updated when items in the DataGrid are being added or deleted (ie, that's when the underlying ItemsSource.CollectionChanged).

Would also be nice if SourceValues could be updated not only on the dataGrid.RowEditEnding event, but anytime the underlying data gets changed outside cell editing.

Performance: Optimize DataGridFilterColumn.GetCellContentData for simple properties

I use DataGridExtensions for the metadata tables in ILSpy. However, on larger tables filtering sometimes takes a long time (3-5 seconds) even for less than 10k entries. When profiling I discovered that a major chunk of the time is spent in DataGridFilterColumn.GetCellContentData to establish and clear the binding to evaluate the SortMemberPath.

Would it be possible to add a setting/option to limit SortMemberPath to simple property names, so that reflection could be used instead of bindings? What else could I do to improve the speed of filtering?

If you are interested in testing this yourself, you can download a nightly build of ILSpy at https://github.com/icsharpcode/ILSpy/actions/runs/622200394 and open the attached
ICSharpCode.Decompiler.zip. As a last step navigate to CustomDebugInformation and filter the "Kind" column as shown below:

image

I would be interested in contributing a fix for this problem, if this is an accepted solution.

Visual Studio XAML Designer Errors

First, thank you for this great project!

I created a fresh and minimal WPF project (.NET Core 3.1) and added the DatagridExtensions Nuget package.

When I want to enable the AutoFilter like so:

<Window x:Class="WpfApp1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:dgx="urn:tom-englert.de/DataGridExtensions"
        mc:Ignorable="d"
        Height="450"
        Width="800">
    <Grid>
        <DataGrid Name="DataGrid"
                  dgx:DataGridFilter.IsAutoFilterEnabled="True"></DataGrid>
    </Grid>
</Window>

I get the following errors:

  • XLS0415 The attachable property 'IsAutoFilterEnabled' was not found in type 'DataGridFilter'
  • XDG0012 The member "IsAutoFilterEnabled" is not recognized or is not accessible.

What am I doing wrong here? The application runs just fine, the filter works. Only the XAML editor throws these errors and says "Invalid Markup".

Thank you!

Programmatic Control of Popup

First, thank you for this great project! Please consider my pull request that I will submit shortly, which aims to help with the following.

Problem #1: in a datatable I would like to add a button that, when clicked, shows the pop-up filter attached to one of the columns and pre-populates the values. This is useful because it is then possible to create specific filters easily in code, while at the same time showing to the user how this filter is created by opening the filter pop-up.

Problem #2: I would also like easier access to certain properties of this custom filter control without having to wire together the popup control, the DataGridFilterColumnControl, and the DataGridFilterColumn through binding as you have done for example with the Filter property,

I will create a pull request that implements this and adds two buttons to the "Customized 2" tab of the demo app.

Implementation of button #1, "Open & Populate a Filter"

Setting values for the Min and Max values is possible and trivial with the existing code. A new "Column5Filter" property is added to Customized2ViewModel and the DataGridFilterColumn.Filter attached property is bound to it in xaml with dgx:DataGridFilterColumn.Filter="{Binding Column5Filter}"

It is then possible to do Column5Filter = new ContentFilter(0.5d, 1d); in the DelegateCommand bound to the button. For this nothing had to be changed in the DataGridExtensions project.

In order to control the visibility of the pop-up when the button is pressed, I added an IsPopupVisible attached property to DataGridFilterColumn, and another dependency property with the same name to DataGridFilterColumnControl, as well as to FilterWithPopupControl, and I also added a Column5PopupVisible property to the Customized2ViewModel, and bound them all to each other much like how the Filter property is implemented in the original code. Now it's possible to do Column5PopupVisible = true; in the DelegateCommand bound to the button to show the pop-up. I did not consider this bad practice because "IsPopupVisible" may well apply to many custom filter controls, so it should be widespread enough to warrant having such a property on DataGridFilterColumn itself. After a bit of debugging and fixes this works fine.

Implementation of button #2, "Change Popup Caption"

Making all the required changes for the IsPopupVisible property to be usable was difficult and time-consuming. Of course, I am not familiar with the project. In any case, it also required changes to be made to files in the DataGridExtensions project itself, which most users may not want to do (since that would put them on a fork of the project). Additionally, a user may create various types of custom filter controls with various properties, where it really wouldn't make sense to also create corresponding properties on the DataGridFilterColumnControl and the DataGridFilterColumn classes. Therefore I also made the following changes.

I defined a DataGridFilterColumnControl attached property in DataGridFilterColumn, and updated the AttachColumnControl method in DataGridFilterHost to inject the filterColumnControl into this property:

public sealed class DataGridFilterHost {
...
        internal void AttachColumnControl(DataGridColumn column, DataGridFilterColumnControl filterColumnControl)
        {
            column.SetFilterHost(this);
            column.SetDataGridFilterColumnControl(filterColumnControl); <-- New line
...

I also created a FilterControl property on DataGridFilterColumnControl, and overrode OnApplyTemplate() so as to set the FilterControl to the actual control generated after the control is drawn:

public class DataGridFilterColumnControl { 
...
        /// <summary>
        /// The actual filter control generated at runtime. 
        /// </summary>
        public Control? FilterControl
        {
            get;
            set;
        }

        /// <summary>
        /// Populate the FilterControl property once the template is applied.
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (VisualTreeHelper.GetChildrenCount(this) == 1
                && VisualTreeHelper.GetChild(this, 0) is Control filterControl)
            {
                FilterControl = filterControl;
            }
        }

This way it becomes possible to do as follows in code:

var dataGridFilterColumnControl = DataGridFilterColumn.GetDataGridFilterColumnControl(dataGridColumn);
if (dataGridFilterColumnControl.FilterControl is IntegerDynamicDualValueFilter integerDynamicDualValueFilter) { 
...

In the above code IntegerDynamicDualValueFilter is a custom filter control in my own project, but it could be any filter control class you've created.

In the sample project I did as follows in order to easily be able to set the caption of the "FilterWithPopupControl" control:

  1. I created a Caption property on the FilterWithPopupControl: public string Caption...
  2. I bound the corresponding textbox to this property: <TextBlock x:Name="Caption" Text="{Binding Path=Caption, ElementName=Control, TargetNullValue='Enter the limits:'}" Margin="0,3" />
  3. I created a property in the viewmodel to be able to access the FilterColumnControl: public DataGridFilterColumnControl Column5FilterColumnControl { get; set; }
  4. Bound this property in xaml: BindingOperations.SetBinding(Column5, DataGridFilterColumn.DataGridFilterColumnControlProperty, new Binding("DataContext.Column5FilterColumnControl") { Source = this, Mode = BindingMode.TwoWay });

It then became possible to do as follows in order to set the caption of the popup dialog:

class Customized2ViewModel : ObservableObject {
...
        public ICommand ProgrammaticAccessToFilterControlCommand => new DelegateCommand(ProgrammaticAccessToFilterControl);

        private void ProgrammaticAccessToFilterControl()
        {
            if (Column5FilterColumnControl.FilterControl is FilterWithPopupControl filterWithPopupControl)
            {
                filterWithPopupControl.Caption = "New Popup Caption:";
                Column5PopupVisible = true;
            }
        }

As you can see now it's possible to control various aspects of a custom filter control without making any changes in the core DataGridExtensions project, and without having to resort to ugly and slow static helper methods that traverse the visual tree. Yes, this is not optimal MVVM and may raise concerns regarding separation of the viewmodel and the view, but it works and makes such logic possible in the future without having to fork the DataGridExtensions project and without having to spend a day trying to understand how it works.

Thanks for considering my PR.

DataGrid in TabControl - Values in TextBoxes lost after tab change

Hi,

I got a small issue when the filtered DataGrid is put inside a TabItem like in the sample project. When I use a filter with TextBox input (e.g. the IntegerGreatherThanFilterControl) and I switch to another tab and back, the input value is no longer displayed. The filter itself is still active, just the input value is no longer visible.
I think this is due to the fact that the TabControl is drawing all the visuals inside a TabItem on demand and doesn't keep them loaded.

Is there a way to keep the input values in the TextBox after tab switches?

Scrolling in DataGrid with arrow up ends in the title filter editor

Scrolling in DataGrid with arrow up ends in the title filter editor (in column header) instead in the first line of data. And it even does not allow to jump back into data rows using arrow down.

Please disable this scroll to column header (better) or at least allow going back to data row area using array down (worse, but still acceptable).

MultipleChoiceFilter does not match on Enums

Selecting an item in popup ListBox does not filter rows in DataGrid when underlying type is not string but:

public enum Permission
{
    None,
    Read,
    Write,
}

To fix that I've changed
https://github.com/tom-englert/DataGridExtensions/blob/480d15443db131a28398c60f73195f52ef94c97f/DataGridExtensionsSample/MultipleChoiceFilter.xaml.cs#L118-L121
to

return ExcludedItems?.Contains(value?.ToString()) != true;

Then it started to filter rows with enum values

Not sure, it's completely valid fix, just wanted to share, might be useful.

Column virtualization is not supported

DataGrid loops between empty/full when I apply a filter that match no row.

To trigger the bug some options are set:

  • can user add row = false
  • column virtualization = true

It seems that the column filtered has to be not visible unless you scroll horizontally (last right column)

image

image

Sample project :
BugDataGrid.zip

(If you put column virtualization = false, then the bug disappear, but the column filtered is on the far right and the scrollbar is not visible anymore => you can't remove the filter)

Missing resources in netcoreapp3.0 target

The Generic.xaml resources aren't included in the netcoreapp3.0 version, and therefore the library doesn't work on that target. Copying these to my app makes everything work properly again.

See the difference bewteen net45 and netcoreapp3.0 versions:

image

Extending the ListBox for MultipleChoiceFilter

I find your DataGridExtensions very good and helpful for my project.
In the process of the project I had the request to add an entry to the ListBox of the MultipleChoiceFilter always automatically:
(Select All) - when activating the checkbox all entries in the ListBox should be selected; when deactivating it all entries in the ListBox should be deselected.
An example of this functionality can be seen with the filters in Microsoft Access tables.
At what point in the MultipleChoiceFilter class should I do that? Please describe a small example if possible.

Method not supported

I added this nuget to my WPF project and enabled AutoFilter on one of my DataGrids. When I typed into the filter boxes an exception was thrown which took me to Line 277 of the DataGridFileHost class. The error message said 'Specified method is not supported.'

My app targets .NET Framework 4.7.2. Is that supported?

Some questions

Hey there,

First one, congratulations about the project, it's amazing!

I have a few questions about the usability:

  1. Can I use the filter only in only a specific column? If so, how do I do it?

  2. Can I use a range to the search? If so, how do I do it?

Thank you!

Coherence between 2 MultipleChoiceFilter

Hello,

I notice a problem when using your excellent library.

When two MultipleChoiceFilter are proposed in a datagrid, the selection of some elements in the first one will modify the results in the datagrid but it has no effect on the values proposed in the second MultipleChoiceFilter.

Can that be done ?

Filtering does not support CollectionViewSource

Setting the DataGrid's AutoGenerateColumns to True and ItemsSource to a CollectionViewSource, the filtering raises an unhandled exception: System.NotSupportedException: 'Specified method is not supported.'

I'd like to use the filtering feature and my data is loaded in a DataTable. Columns are unknown at design time and may change on user's input. A workaround would also be welcomed.

namespace TestGrid
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
//Doesn't work
//dataGrid.ItemsSource = GetData().DefaultView;

  //Doesn't work
  CollectionViewSource mycollection = new CollectionViewSource();
  mycollection.Source = GetDataTableData();
  dataGrid.ItemsSource = mycollection.View;

}

public DataTable GetDataTableData()
{
  DataTable qData = new DataTable();
  qData.Columns.Add("Name", typeof(String));
  qData.Columns.Add("Age", typeof(int));
  DataRow dr = qData.NewRow();
  dr["Name"] = "Bob";
  dr["Age"] = 98;
  qData.Rows.Add(dr);     
  return qData;
}   

}
}

Accessing the filtered data from viewmodel?

Have a WPF Page using a MultiSelectDataGrid and its ItemSource is binding to a CollectionViewSource within a viewmodel. DGX filtering works beautifully, but I'm not sure how I can access/navigate the filtered data - whether from the ViewModel's CollectionViewSource or directly from XAML CodeBehind. With filters applied, my CollectionViewSource data always contains the unfiltered list.

Any examples that show how to access the filtered data?

After enabling filtering HeaderStringFormats are being ignored

HeaderStringFormat is being ignored on columns with IsFilterVisible="True" (or default value), for example in a DataGrid with two identical columns:

<DataGrid xmlns:sys="clr-namespace:System;assembly=mscorlib"
          xmlns:dgx="urn:tom-englert.de/DataGridExtensions"
          dgx:DataGridFilter.IsAutoFIlterEnabled="True">
   <DataGrid.Columns>
      <DataGridTextColumn Header="{Binding Source={x:Static sys:DateTime.Now}}" HeaderStringFormat='{}Year: {0:yyyy}'
                          dgx:DataGridFilterColumn.IsFilterVisible="False"/>
      <DataGridTextColumn Header="{Binding Source={x:Static sys:DateTime.Now}}" HeaderStringFormat='{}Year: {0:yyyy}'
                          dgx:DataGridFilterColumn.IsFilterVisible="True"/>
   </DataGrid.Columns>
</DataGrid>

the first column's header is rendered correctly as "Year: 2020" while the second one with filter enabled is rendered incorrecty as "9/8/2020 13:04" - HeaderStringFormat is being ignored.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.