problem with filter

Apr 17, 2012 at 6:55 PM

at runtime appear the follow error:

System.ArgumentNullException was unhandled
  Message=El valor no puede ser nulo.
Nombre del parámetro: source
  Source=System.Core
  ParamName=source
  StackTrace:
       en System.Linq.Enumerable.Count[TSource](IEnumerable`1 source, Func`2 predicate)
       en ExtendedGrid.Styles.DataGridGeneric.AutoFilterMouseDown(Object sender, MouseButtonEventArgs e)
       en System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
       en System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
       en System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
       en System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       en System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
       en System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
       en System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
       en System.Windows.Input.InputManager.ProcessStagingArea()
       en System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
       en System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
       en System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
       en System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       en System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       en MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       en MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       en System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       en MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       en System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
       en MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       en MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
       en System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       en System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
       en System.Windows.Threading.Dispatcher.Run()
       en System.Windows.Application.RunDispatcher(Object ignore)
       en System.Windows.Application.RunInternal(Window window)
       en System.Windows.Application.Run(Window window)
       en System.Windows.Application.Run()
       en WpfApplicationDemoEXE.App.Main() en C:\SIOP\Investigacion\EjemploWPF\EjemploWPF\WpfApplicationDemoEXE\obj\x86\Debug\App.g.cs:línea 0
       en System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       en System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       en Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       en System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       en System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       en System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       en System.Threading.ThreadHelper.ThreadStart()
  InnerException:

the source for ExtendedDataGrid is a ObservableCollection

Coordinator
Apr 17, 2012 at 9:00 PM

Hi

 

Spanish

Buscando en ella .. ¿Puede usted por favor hágamelo saber qué tipo es el origen de datos?

 

English

Looking into it..Can you please let me know what type is your Data Source?

 

Regards,

Bhushan Poojary

Coordinator
Apr 17, 2012 at 9:04 PM

I saw your last line the Data source cannot be ObservableCollection when your using ObservableCollection ..Please use DataTable instead. 

If you want help regarding how will you convert your observableColelction to DataTable plese feel free to contact me.

 

Advice use Observable collection for normal controls like comboBox,ListBox etc etc.

Use DataTable with DataGrid because it optimizes performance when used.

 

SPANISH

Vi su última línea de la fuente de datos no puede ser ObservableCollectionObservableCollection cuando su uso .. Por favor, use DataTable en su lugar.

Si desea ayuda con respecto a cómo va a convertir su observableColelction deDataTable plese no dude en ponerse en contacto conmigo.



Consejos de uso de la colección observable de los controles normales, comoComboBox, ListBox, etc, etc

Utilice DataTable con DataGrid, ya que optimiza el rendimiento cuando se utiliza.

 

Regards,

Bhushan Poojary

Coordinator
Apr 17, 2012 at 9:15 PM

If you still want to use ObservableCollection as DataSource , I will try to tweak my code to take care of Observable collection but only issue is that filtering operation in ObservableCollection is not straight forward as DataTable.

Apr 22, 2012 at 4:23 AM

I usually ItemsSource or DataContext my DataGrids with List<> from a LinQ to SQL query. Perhaps I should work on returning a DataTable / DataView instead. Reviewing the AutoFilterHelper Class shows that refactoring to use a List<> would not be straight forward.

 

Overall, it is a very nice tool - very easy to use and the export to excel function works very nicely.

Coordinator
Apr 22, 2012 at 5:20 AM

Thanks RChibnik :-) .

 

Regards,

Bhushan Poojary

Apr 23, 2012 at 5:10 PM

For those of us using LINQ to SQL, this is a simple way of setting the datagrid's DataContext to a DataTable:

var linqQuery = (from recordSet in dataContext.tableName select rs);

IDbCommand cmd = dataContext.GetCommand((object)linqQuery as IQueryable); 

SqlDataAdapter adapter = new SqlDataAdapter();           

adapter.SelectCommand = (SqlCommand)cmd;           

DataTable dt = new DataTable("sd");

try           

{               

cmd.Connection.Open();               

adapter.FillSchema(dt, SchemaType.Source);               

adapter.Fill(dt);           

}           

finally           

{               

cmd.Connection.Close();           

}

dataGrid.DataContext = dt;

Apr 23, 2012 at 6:00 PM

There are still a couple of defects (in my implementation) that I've found when checking / unchecking the filter. I'll try to get some more specifics. Some changes that I would propose:

- Default to "AllowAutoFilter=False" in the implementation. This way you can use <DataGridTextColumn> when you dont need the filtering - useful for converting from DataGrid to ExtendedDataGrid.

- Select All should be checked by default, since when the filter is not applied, SelectAll is implied.

- empty DataGrid throwns an exception when trying to AutoFilter - should be caught in the library;

 

There seems to be a defect related to select all and unselecting values where the filter generator includes repeated values in the filter. This causes a filter string too long that throws an exception. I'll try to work out a set of reproducable steps to recreate it.

Coordinator
Apr 23, 2012 at 6:08 PM

Thanks RChibnik..

 

I am also thinking about changing the code for AutoFilter. But problem with .NET is that it deals with RowFilter which accepts string.But dealing with dyanmic data it become hard to manage.

But I have something in my mind.Once I get time in weekend will try to push more robust code..I did some fare round of testing with normal DataTable worked fine. Will check out with your implementation.

Apr 23, 2012 at 7:31 PM

Somehow, when "Select All" is becomes checked, multiple instances of each row is included. If you uncheck Select All, then uncheck on of the rows, only the first instance of the filter is removed, so the filter is not applied (since it occurs many more times in the filter.) I'm trying to catch the event when they all get added on Select All being checked but have so far been unsuccessful.

 

I'll keep you posted.

Apr 25, 2012 at 2:29 AM

I added 5000 rows to the auto filter section of the test program and couldnt recreate my problem, although filtering was painfully slow.

Coordinator
Apr 25, 2012 at 3:40 AM

Hi

Can u post solutoion here?I will be happy to fix it.

Regards,
Bhushan Poojary

On Apr 25, 2012 6:59 AM, "RChibnik" <notifications@codeplex.com> wrote:

From: RChibnik

I added 5000 rows to the auto filter section of the test program and couldnt recreate my problem, although filtering was painfully slow.

Read the full discussion online.

To add a post to this discussion, reply to this email (WPFExtendedDataGrid@discussions.codeplex.com)

To start a new discussion for this project, email WPFExtendedDataGrid@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Apr 25, 2012 at 7:45 PM
bpoojary wrote:

Hi

Can u post solutoion here?I will be happy to fix it.

Thanks for looking at it.

I have solution that recreates the problem without dependency on the database. It consists of a Xaml, CS and CSV file. I have them in a zip, but am unsure of how to post them. I pasted the code below. It seems ok.

Create a new solution named ExtendedDataGridTest with reference to ExtendedGrid.dll

Paste the Xaml into MainWindow.Xaml, the C# code into MainWindow.cs and the CSV into a text file named DataSource.csv in the bin folder.

Choose a column (Security Name or Security ID) and "select all", then notice that unselecting one of the nine security IDs does not remove them from the filter. This may be due to the trailing spaces. I believe that multiple entries are made to the filter - perhaps because they get trimmed when added to the filter, but they are compared to an untrimmed version, but I have not observed that in the code.

XAML---- Cut Here

<Window x:Class="ExtendedDataGridTest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:exdg="clr-namespace:ExtendedGrid.ExtendedGridControl;assembly=ExtendedGrid"
        xmlns:ExtendedColumn="clr-namespace:ExtendedGrid.ExtendedColumn;assembly=ExtendedGrid"
        Title="MainWindow" Height="350" Width="525" 
        Loaded="WindowLoaded" xmlns:fluent="clr-namespace:Fluent;assembly=Fluent">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="273*" />
            <RowDefinition Height="38*" />
        </Grid.RowDefinitions>
        <exdg:ExtendedDataGrid AutoGenerateColumns="False" Margin="12,12,12,6" x:Name="dataGrid" ItemsSource="{Binding}">
            <DataGrid.Columns>
                <ExtendedColumn:ExtendedDataGridTextColumn Header="Fund#" Binding="{Binding Path=fundNum}" AllowAutoFilter="True"/>
                <ExtendedColumn:ExtendedDataGridTextColumn  Header="Security Name" Binding="{Binding Path=securityLongName}" Width="*" AllowAutoFilter="True"/>
                <ExtendedColumn:ExtendedDataGridTextColumn  Header="SecId" Binding="{Binding Path=securityId}" Width="Auto" AllowAutoFilter="True"/>
                <ExtendedColumn:ExtendedDataGridTextColumn  Header="Purchase" Binding="{Binding Path=purchaseDate}" Width="Auto" AllowAutoFilter="True"/>
                <ExtendedColumn:ExtendedDataGridTextColumn  Header="ST/LT" Binding="{Binding Path=shortLongTerm}" Width="Auto" AllowAutoFilter="True"/>
                <ExtendedColumn:ExtendedDataGridTextColumn  Header="Economic" Binding="{Binding Path=economicGainLoss}" Width="Auto" AllowAutoFilter="False"/>

            </DataGrid.Columns>
        </exdg:ExtendedDataGrid>
        <Button Content="_Hide" Grid.Row="1" Height="23" HorizontalAlignment="Right" Margin="0,3,93,0" Name="btnHide" VerticalAlignment="Top" Width="75" Click="btnHide_Click" />
        <Button Content="_Export" Grid.Row="1" Height="23" HorizontalAlignment="Right" Margin="0,3,12,0" Name="btnExport" VerticalAlignment="Top" Width="75" Click="btnExport_Click" />
        <Button Content="_Populate" Height="23" HorizontalAlignment="Right" Margin="0,3,174,0" Name="btnPopulate" VerticalAlignment="Top" Width="75" Grid.Row="1" Click="btnPopulate_Click" />
        <TextBlock Grid.Row="1" Height="35" HorizontalAlignment="Left" Margin="12,3,0,0" Name="textBlock1" Text="{Binding Path=dataGrid.ItemsSource.RowFilter}" VerticalAlignment="Top" Width="239" />
    </Grid>
</Window>

C# Code --- Cut Here
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ExtendedGrid.Classes;
using System.Data;
using System.Data.SqlClient;
using System.IO;

namespace ExtendedDataGridTest
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        DataDataContext ddc = new DataDataContext();
        public MainWindow()
        {
            InitializeComponent();
        }

        private void WindowLoaded(object sender, RoutedEventArgs e)
        {
        }

        private void btnExport_Click(object sender, RoutedEventArgs e)
        {
            string txtExcelFileLocation = @"e:\export.xls";
            try {
                dataGrid.ExportToExcel("Bhushan", txtExcelFileLocation, (ExcelTableStyle)0, true);
            }
            catch {}

        }


        private void btnHide_Click(object sender, RoutedEventArgs e)
        {
            // toggle visibility
            if ((Visibility.Hidden == dataGrid.Columns[dataGrid.Columns.Count - 1].Visibility )) {
                dataGrid.Columns[dataGrid.Columns.Count - 1].Visibility =Visibility.Visible ;
                btnHide.Content = "_Hide";
            }
            else {
                dataGrid.Columns[dataGrid.Columns.Count - 1].Visibility =Visibility.Hidden;
                btnHide.Content = "Un_Hide";
            }

        }

        private void btnPopulate_Click(object sender, RoutedEventArgs e)
        {
            dataGrid.DataContext= (ReadFile("datasource.csv",",",null));
        }


        /// <summary>
        /// Read the file and return a DataTable
        /// </summary>
        /// <param name="filename">File to read</param>
        /// <param name="delimiter">Delimiting string</param>
        /// <param name="columnNames">Array of column names</param>
        /// <returns>Populated DataTable</returns>
        public static DataTable ReadFile(string filename, string delimiter, string[] columnNames)
        {
            //  Create the new table
            DataTable data = new DataTable();
            data.Locale = System.Globalization.CultureInfo.CurrentCulture;

            //  Check file
            if (!File.Exists(filename))
                throw new FileNotFoundException("File not found", filename);

            //  Process the file line by line
            string line;
            using (TextReader tr = new StreamReader(filename, Encoding.Default))
            {
                //  If column names were not passed, we'll read them from the file
                if (columnNames == null)
                {
                    //  Get the first line
                    line = tr.ReadLine();
                    if (string.IsNullOrEmpty(line))
                        throw new IOException("Could not read column names from file.");
                    columnNames = line.Split(new string[] { delimiter }, StringSplitOptions.RemoveEmptyEntries);
                }

                //  Add the columns to the data table
                foreach (string colName in columnNames)
                    data.Columns.Add(colName);

                //  Read the file
                string[] columns;
                while ((line = tr.ReadLine()) != null)
                {
                    columns = line.Split(new string[] { delimiter }, StringSplitOptions.None);
                    //  Ensure we have the same number of columns
                    if (columns.Length != columnNames.Length)
                    {
                        string message = "Data row has {0} columns and {1} are defined by column names.";
                        throw new DataException(string.Format(message, columns.Length, columnNames.Length));
                    }
                    data.Rows.Add(columns);
                }
            }
            return data;

        }
    }
}

--- CSV Code - cut here

fundNum,securityLongName,securityId,purchaseDate,shortLongTerm,economicGainLoss
1093,US DOLLARS,CASHUSD             ,NULL,NULL,0
1093,FUND-1 BNDMARKET,ABCL98              ,8/6/2009,LT,978
1093,FUND-1 BNDMARKET,ABCL98              ,7/13/2009,LT,14385
1093,FUND-1 BNDMARKET,ABCL98              ,3/16/2009,LT,7014
1093,FUND-2 S&P 500,EFGMBC                            ,9/6/2011,ST,1042
1093,FUND-2 S&P 500,EFGMBC                            ,9/9/2011,ST,650
1093,FUND-2 S&P 500,EFGMBC                            ,9/30/2011,ST,1555
1093,FUND-2 S&P 500,EFGMBC                            ,9/2/2011,ST,2170
1093,FUND-2 S&P 500,EFGMBC                            ,10/3/2011,ST,1914
1093,FUND-2 S&P 500,EFGMBC                            ,10/6/2011,ST,319
1093,FUND-3 EXT MKT,HIJMBD              ,9/30/2011,ST,714
1093,FUND-3 EXT MKT,HIJMBD              ,10/3/2011,ST,955
1093,FUND-3 EXT MKT,HIJMBD              ,8/26/2011,ST,329897
1093,FUND-3 EXT MKT,HIJMBD              ,10/3/2011,ST,94738
1093,FUND-3 EXT MKT,HIJMBD              ,11/25/2011,ST,53
1093,FUND-3 EXT MKT,HIJMBD              ,4/9/2012,ST,-54
1093,FUND-4  INT EQ (30),KLMMBD              ,12/2/2011,ST,58
1093,FUND-4  INT EQ (30),KLMMBD              ,10/7/2011,ST,120
1093,FUND-4  INT EQ (30),KLMMBD              ,12/14/2011,ST,228
1093,FUND-4  INT EQ (30),KLMMBD              ,9/7/2011,ST,144
1093,FUND-4  INT EQ (30),KLMMBD              ,9/16/2011,ST,485
1093,FUND-4  INT EQ (30),KLMMBD              ,1/6/2012,ST,228
1093,FUND-5 CAP INCRESE CL Y,AAA79A404           ,3/10/2008,LT,345
1093,FUND-5 CAP INCRESE CL Y,AAA79A404           ,7/27/2010,LT,7228
1093,FUND-5 CAP INCRESE CL Y,AAA79A404           ,2/10/2009,LT,1098
1093,FUND-5 CAP INCRESE CL Y,AAA79A404           ,12/17/2008,LT,297
1093,FUND-5 CAP INCRESE CL Y,AAA79A404           ,5/27/2010,LT,986
1093,FUND-5 CAP INCRESE CL Y,AAA79A404           ,7/1/2009,LT,1378
1093,FUND-6 VALUE ,BBB80J816           ,12/2/2010,LT,146
1093,FUND-6 VALUE ,BBB80J816           ,3/12/2009,LT,119
1093,FUND-6 VALUE ,BBB80J816           ,11/7/2011,ST,50
1093,FUND-6 VALUE ,BBB80J816           ,12/10/2009,LT,250
1093,FUND-6 VALUE ,BBB80J816           ,7/9/2008,LT,-28
1093,FUND-6 VALUE ,BBB80J816           ,10/2/2009,LT,1471
1093,FUND-7 SMALL AND MID CAP CLASS Y,CCC81F409           ,5/18/2009,LT,4621
1093,FUND-7 SMALL AND MID CAP CLASS Y,CCC81F409           ,12/10/2009,LT,336
1093,FUND-7 SMALL AND MID CAP CLASS Y,CCC81F409           ,8/5/2009,LT,138
1093,FUND-7 SMALL AND MID CAP CLASS Y,CCC81F409           ,6/17/2009,LT,1737
1093,FUND-7 SMALL AND MID CAP CLASS Y,CCC81F409           ,3/18/2010,LT,249
1093,FUND-7 SMALL AND MID CAP CLASS Y,CCC81F409           ,1/13/2010,LT,1434

Coordinator
Apr 25, 2012 at 11:19 PM

Hi

I will revert back on saturday. Can you assisgn ItemSource of the datagrid instead of the datacontext, for e.g datagrid.ItemSource=datatable.DefaultView.

Regards,
Bhushan Poojary

On Apr 26, 2012 12:15 AM, "RChibnik" <notifications@codeplex.com> wrote:

From: RChibnik

bpoojary wrote:

Hi

Can u post solutoion here?I will be happy to fix it.

Thanks for looking at it.

I have solution that recreates the problem without dependency on the database. It consists of a Xaml, CS and CSV file. I have them in a zip, but am unsure of how to post them. I pasted the code below. It seems ok.

Create a new solution named ExtendedDataGridTest with reference to ExtendedGrid.dll

Paste the Xaml into MainWindow.Xaml, the C# code into MainWindow.cs and the CSV into a text file named DataSource.csv in the bin folder.

Choose a column (Security Name or Security ID) and "select all", then notice that unselecting one of the nine security IDs does not remove them from the filter. This may be due to the trailing spaces. I believe that multiple entries are made to the filter - perhaps because they get trimmed when added to the filter, but they are compared to an untrimmed version, but I have not observed that in the code.

XAML---- Cut Here

<Window x:Class="ExtendedDataGridTest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:exdg="clr-namespace:ExtendedGrid.ExtendedGridControl;assembly=ExtendedGrid"
        xmlns:ExtendedColumn="clr-namespace:ExtendedGrid.ExtendedColumn;assembly=ExtendedGrid"
        Title="MainWindow" Height="350" Width="525" 
        Loaded="WindowLoaded" xmlns:fluent="clr-namespace:Fluent;assembly=Fluent">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="273*" />
            <RowDefinition Height="38*" />
        </Grid.RowDefinitions>
        <exdg:ExtendedDataGrid AutoGenerateColumns="False" Margin="12,12,12,6" x:Name="dataGrid" ItemsSource="{Binding}">
            <DataGrid.Columns>
                <ExtendedColumn:ExtendedDataGridTextColumn Header="Fund#" Binding="{Binding Path=fundNum}" AllowAutoFilter="True"/>
                <ExtendedColumn:ExtendedDataGridTextColumn  Header="Security Name" Binding="{Binding Path=securityLongName}" Width="*" AllowAutoFilter="True"/>
                <ExtendedColumn:ExtendedDataGridTextColumn  Header="SecId" Binding="{Binding Path=securityId}" Width="Auto" AllowAutoFilter="True"/>
                <ExtendedColumn:ExtendedDataGridTextColumn  Header="Purchase" Binding="{Binding Path=purchaseDate}" Width="Auto" AllowAutoFilter="True"/>
                <ExtendedColumn:ExtendedDataGridTextColumn  Header="ST/LT" Binding="{Binding Path=shortLongTerm}" Width="Auto" AllowAutoFilter="True"/>
                <ExtendedColumn:ExtendedDataGridTextColumn  Header="Economic" Binding="{Binding Path=economicGainLoss}" Width="Auto" AllowAutoFilter="False"/>

            </DataGrid.Columns>
        </exdg:ExtendedDataGrid>
        <Button Content="_Hide" Grid.Row="1" Height="23" HorizontalAlignment="Right" Margin="0,3,93,0" Name="btnHide" VerticalAlignment="Top" Width="75" Click="btnHide_Click" />
        <Button Content="_Export" Grid.Row="1" Height="23" HorizontalAlignment="Right" Margin="0,3,12,0" Name="btnExport" VerticalAlignment="Top" Width="75" Click="btnExport_Click" />
        <Button Content="_Populate" Height="23" HorizontalAlignment="Right" Margin="0,3,174,0" Name="btnPopulate" VerticalAlignment="Top" Width="75" Grid.Row="1" Click="btnPopulate_Click" />
        <TextBlock Grid.Row="1" Height="35" HorizontalAlignment="Left" Margin="12,3,0,0" Name="textBlock1" Text="{Binding Path=dataGrid.ItemsSource.RowFilter}" VerticalAlignment="Top" Width="239" />
    </Grid>
</Window>

C# Code --- Cut Here
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ExtendedGrid.Classes;
using System.Data;
using System.Data.SqlClient;
using System.IO;

namespace ExtendedDataGridTest
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        DataDataContext ddc = new DataDataContext();
        public MainWindow()
        {
            InitializeComponent();
        }

        private void WindowLoaded(object sender, RoutedEventArgs e)
        {
        }

        private void btnExport_Click(object sender, RoutedEventArgs e)
        {
            string txtExcelFileLocation = @"e:\export.xls";
            try {
                dataGrid.ExportToExcel("Bhushan", txtExcelFileLocation, (ExcelTableStyle)0, true);
            }
            catch {}

        }


        private void btnHide_Click(object sender, RoutedEventArgs e)
        {
            // toggle visibility
            if ((Visibility.Hidden == dataGrid.Columns[dataGrid.Columns.Count - 1].Visibility )) {
                dataGrid.Columns[dataGrid.Columns.Count - 1].Visibility =Visibility.Visible ;
                btnHide.Content = "_Hide";
            }
            else {
                dataGrid.Columns[dataGrid.Columns.Count - 1].Visibility =Visibility.Hidden;
                btnHide.Content = "Un_Hide";
            }

        }

        private void btnPopulate_Click(object sender, RoutedEventArgs e)
        {
            dataGrid.DataContext= (ReadFile("datasource.csv",",",null));
        }


        /// <summary>
        /// Read the file and return a DataTable
        /// </summary>
        /// <param name="filename">File to read</param>
        /// <param name="delimiter">Delimiting string</param>
        /// <param name="columnNames">Array of column names</param>
        /// <returns>Populated DataTable</returns>
        public static DataTable ReadFile(string filename, string delimiter, string[] columnNames)
        {
            //  Create the new table
            DataTable data = new DataTable();
            data.Locale = System.Globalization.CultureInfo.CurrentCulture;

            //  Check file
            if (!File.Exists(filename))
                throw new FileNotFoundException("File not found", filename);

            //  Process the file line by line
            string line;
            using (TextReader tr = new StreamReader(filename, Encoding.Default))
            {
                //  If column names were not passed, we'll read them from the file
                if (columnNames == null)
                {
                    //  Get the first line
                    line = tr.ReadLine();
                    if (string.IsNullOrEmpty(line))
                        throw new IOException("Could not read column names from file.");
                    columnNames = line.Split(new string[] { delimiter }, StringSplitOptions.RemoveEmptyEntries);
                }

                //  Add the columns to the data table
                foreach (string colName in columnNames)
                    data.Columns.Add(colName);

                //  Read the file
                string[] columns;
                while ((line = tr.ReadLine()) != null)
                {
                    columns = line.Split(new string[] { delimiter }, StringSplitOptions.None);
                    //  Ensure we have the same number of columns
                    if (columns.Length != columnNames.Length)
                    {
                        string message = "Data row has {0} columns and {1} are defined by column names.";
                        throw new DataException(string.Format(message, columns.Length, columnNames.Length));
                    }
                    data.Rows.Add(columns);
                }
            }
            return data;

        }
    }
}

--- CSV Code - cut here

fundNum,securityLongName,securityId,purchaseDate,shortLongTerm,economicGainLoss
1093,US DOLLARS,CASHUSD             ,NULL,NULL,0
1093,FUND-1 BNDMARKET,ABCL98              ,8/6/2009,LT,978
1093,FUND-1 BNDMARKET,ABCL98              ,7/13/2009,LT,14385
1093,FUND-1 BNDMARKET,ABCL98              ,3/16/2009,LT,7014
1093,FUND-2 S&P 500,EFGMBC                            ,9/6/2011,ST,1042
1093,FUND-2 S&P 500,EFGMBC                            ,9/9/2011,ST,650
1093,FUND-2 S&P 500,EFGMBC                            ,9/30/2011,ST,1555
1093,FUND-2 S&P 500,EFGMBC                            ,9/2/2011,ST,2170
1093,FUND-2 S&P 500,EFGMBC                            ,10/3/2011,ST,1914
1093,FUND-2 S&P 500,EFGMBC                            ,10/6/2011,ST,319
1093,FUND-3 EXT MKT,HIJMBD              ,9/30/2011,ST,714
1093,FUND-3 EXT MKT,HIJMBD              ,10/3/2011,ST,955
1093,FUND-3 EXT MKT,HIJMBD              ,8/26/2011,ST,329897
1093,FUND-3 EXT MKT,HIJMBD              ,10/3/2011,ST,94738
1093,FUND-3 EXT MKT,HIJMBD              ,11/25/2011,ST,53
1093,FUND-3 EXT MKT,HIJMBD              ,4/9/2012,ST,-54
1093,FUND-4  INT EQ (30),KLMMBD              ,12/2/2011,ST,58
1093,FUND-4  INT EQ (30),KLMMBD              ,10/7/2011,ST,120
1093,FUND-4  INT EQ (30),KLMMBD              ,12/14/2011,ST,228
1093,FUND-4  INT EQ (30),KLMMBD              ,9/7/2011,ST,144
1093,FUND-4  INT EQ (30),KLMMBD              ,9/16/2011,ST,485
1093,FUND-4  INT EQ (30),KLMMBD              ,1/6/2012,ST,228
1093,FUND-5 CAP INCRESE CL Y,AAA79A404           ,3/10/2008,LT,345
1093,FUND-5 CAP INCRESE CL Y,AAA79A404           ,7/27/2010,LT,7228
1093,FUND-5 CAP INCRESE CL Y,AAA79A404           ,2/10/2009,LT,1098
1093,FUND-5 CAP INCRESE CL Y,AAA79A404           ,12/17/2008,LT,297
1093,FUND-5 CAP INCRESE CL Y,AAA79A404           ,5/27/2010,LT,986
1093,FUND-5 CAP INCRESE CL Y,AAA79A404           ,7/1/2009,LT,1378
1093,FUND-6 VALUE ,BBB80J816           ,12/2/2010,LT,146
1093,FUND-6 VALUE ,BBB80J816           ,3/12/2009,LT,119
1093,FUND-6 VALUE ,BBB80J816           ,11/7/2011,ST,50
1093,FUND-6 VALUE ,BBB80J816           ,12/10/2009,LT,250
1093,FUND-6 VALUE ,BBB80J816           ,7/9/2008,LT,-28
1093,FUND-6 VALUE ,BBB80J816           ,10/2/2009,LT,1471
1093,FUND-7 SMALL AND MID CAP CLASS Y,CCC81F409           ,5/18/2009,LT,4621
1093,FUND-7 SMALL AND MID CAP CLASS Y,CCC81F409           ,12/10/2009,LT,336
1093,FUND-7 SMALL AND MID CAP CLASS Y,CCC81F409           ,8/5/2009,LT,138
1093,FUND-7 SMALL AND MID CAP CLASS Y,CCC81F409           ,6/17/2009,LT,1737
1093,FUND-7 SMALL AND MID CAP CLASS Y,CCC81F409           ,3/18/2010,LT,249
1093,FUND-7 SMALL AND MID CAP CLASS Y,CCC81F409           ,1/13/2010,LT,1434

Read the full discussion online.

To add a post to this discussion, reply to this email (WPFExtendedDataGrid@discussions.codeplex.com)

To start a new discussion for this project, email WPFExtendedDataGrid@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Apr 26, 2012 at 3:36 PM

dataGrid.ItemSource=datatable.DefaultView.

Produces the same result.

Suspecting that it had to do with trailing blanks, I removed the trailing blanks from all fields, and the problem persists.

Coordinator
Apr 26, 2012 at 4:40 PM

Ok thought so. Give me 48 hrs will definetly give u good solution.

On Apr 26, 2012 8:06 PM, "RChibnik" <notifications@codeplex.com> wrote:

From: RChibnik

dataGrid.ItemSource=datatable.DefaultView.

Produces the same result.

Suspecting that it had to do with trailing blanks, I removed the trailing blanks from all fields, and the problem persists.

Read the full discussion online.

To add a post to this discussion, reply to this email (WPFExtendedDataGrid@discussions.codeplex.com)

To start a new discussion for this project, email WPFExtendedDataGrid@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Coordinator
Apr 28, 2012 at 6:21 AM

Hi

Can you use below link to download the demo application (In folder you can see Extendeddatagrid.dll)

http://wpfextendeddatagrid.codeplex.com/Download/AttachmentDownload.ashx?ProjectName=wpfextendeddatagrid&WorkItemId=367&FileAttachmentId=175

This project is in Beta stage but kindly test this dll works fine for you or not , I will move the auto filter code or the entire product here.

 

Regards,

Bhushan Poojary

Apr 28, 2012 at 8:13 PM

Did you compile this in 3.5 using WPFToolkit? I'm getting "Cannot resolve Dependency to assembly WPFToolkit." so I am unable to test.

I'm using .NET 4.0.

Coordinator
Apr 28, 2012 at 8:24 PM

Hi

I will give u latest one with. Net 4.0 which dosent require wpfcontrplkit.
Gove me 45 mins.

On Apr 29, 2012 12:43 AM, "RChibnik" <notifications@codeplex.com> wrote:

From: RChibnik

Did you compile this in 3.5 using WPFToolkit? I'm getting "Cannot resolve Dependency to assembly WPFToolkit." so I am unable to test.

I'm using .NET 4.0.

Read the full discussion online.

To add a post to this discussion, reply to this email (WPFExtendedDataGrid@discussions.codeplex.com)

To start a new discussion for this project, email WPFExtendedDataGrid@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Coordinator
Apr 28, 2012 at 8:54 PM

Or till the mean time u can add wpftoolkit dll.

On Apr 29, 2012 12:54 AM, "bhushan poojary" <bhushanpoojary@gmail.com> wrote:

Hi

I will give u latest one with. Net 4.0 which dosent require wpfcontrplkit.
Gove me 45 mins.

On Apr 29, 2012 12:43 AM, "RChibnik" <notifications@codeplex.com> wrote:

From: RChibnik

Did you compile this in 3.5 using WPFToolkit? I'm getting "Cannot resolve Dependency to assembly WPFToolkit." so I am unable to test.

I'm using .NET 4.0.

Read the full discussion online.

To add a post to this discussion, reply to this email (WPFExtendedDataGrid@discussions.codeplex.com)

To start a new discussion for this project, email WPFExtendedDataGrid@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Apr 28, 2012 at 9:41 PM

Adding the WPFToolkit did not work. I look forward to the updated DLL. Thanks for the quick turn-around.

Coordinator
Apr 28, 2012 at 9:43 PM
I am doing the same removing wpfcontrolkit.dll is little tricky stuff half way through.

On Sun, Apr 29, 2012 at 2:11 AM, RChibnik <notifications@codeplex.com> wrote:

From: RChibnik

Adding the WPFToolkit did not work. I look forward to the updated DLL. Thanks for the quick turn-around.

Read the full discussion online.

To add a post to this discussion, reply to this email (WPFExtendedDataGrid@discussions.codeplex.com)

To start a new discussion for this project, email WPFExtendedDataGrid@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Coordinator
Apr 28, 2012 at 11:10 PM

Hi

I am facing issue while removing wpfcontrolkit.dll because latest one which by defualt dosent support GroupByData class.Which I used for Grouping.

Sreps to use the exisiting full feature dll which Ibsent to you.
1. Add ExtendedDataGrid.dll from my new zip file.
2. Simmilarly add wpftoolkit.dll from same zip fole.
3. In your project to remove ambiguity use wpftoolkit.dll DataGrid control and its component and rest of fhe controls u can use System.Control namespace.

If this also dosent work give me test project i will fix it for you.

On Apr 29, 2012 2:13 AM, "bhushan poojary" <bhushanpoojary@gmail.com> wrote:
I am doing the same removing wpfcontrolkit.dll is little tricky stuff half way through.

On Sun, Apr 29, 2012 at 2:11 AM, RChibnik <notifications@codeplex.com> wrote:

From: RChibnik

Adding the WPFToolkit did not work. I look forward to the updated DLL. Thanks for the quick turn-around.

Read the full discussion online.

To add a post to this discussion, reply to this email (WPFExtendedDataGrid@discussions.codeplex.com)

To start a new discussion for this project, email WPFExtendedDataGrid@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Apr 28, 2012 at 11:24 PM
Edited Apr 29, 2012 at 1:26 AM

I get a message about "trial version".

After pressing ok on the dialog box, the app crashes.

Apr 29, 2012 at 2:18 AM
bpoojary wrote:

 

>I am facing issue while removing wpfcontrolkit.dll because latest one which by defualt dosent support GroupByData class.Which I used for Grouping.

Don't know what you mean by "wpfcontrolkit.dll" - do you mean removing WPFToolKit?

>If this also dosent work give me test project i will fix it for you.

If you create a new project with the three parts above (CS, XAML and CSV file) you should be able to recreate the problem.
Continued testing on my part shows that select all affects that filter sporadically - sometimes it works, for some of the values, and not for others. I am trying to trap the "select all" event and catch the filter creation.
Any advise would be helpful.
Coordinator
Apr 29, 2012 at 5:27 AM

Hi

I have added that on purpose. U use it and test it will send u the one which dosent give you that message. This was supposed to be paid one, but I think I will push to open source codeplex soon for free. Do you like the added new features?

On Apr 29, 2012 3:54 AM, "RChibnik" <notifications@codeplex.com> wrote:

From: RChibnik

I get a message about "trial version".

Read the full discussion online.

To add a post to this discussion, reply to this email (WPFExtendedDataGrid@discussions.codeplex.com)

To start a new discussion for this project, email WPFExtendedDataGrid@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Apr 30, 2012 at 2:40 AM

I am able to run the demo project you supplied.

When I try to include the two DLL's (WPFToolkit and ExtendedGrid.DLL) to my solution I get a number of unexpected errors,like "DataGrid.Columns" is not defined on ExtendedGrid 

and

Error 1 The tag 'ExtendedGridControl' does not exist in XML namespace 'clr-namespace:ExtendedGrid.ExtendedGridControl;assembly=ExtendedGrid'. Line 15 Position 10. E:\Projects\WPF\ExtGridTest\MainWindow.xaml 15 10 ExtGridTest

The new features look intriguing but dont seem to be as robust as the code posted in Downloads.

I would be happy to test it further and applaud your efforts and encourage you to continue your open source efforts. It really is a nice control thats easy to work with.

Thanks for your help

Regards

Ron

Coordinator
Apr 30, 2012 at 3:24 AM

Hi

Give me you demo solution. You can use sky drive to post your solution as a zip file(Those error I have also seen but actual cause of error is different, When actual cause of error is removed these error also goes, these are designers error). Scroll for unique and diffrent error and fix the ambiguity. (For grid related stuff any where in code as of now use wpfcontrolkit namespace for rest you can use .NET 4.0 namespace, this itself can solve your problem, Our gird is still using wpfcontrolkit namespace dll and it understands only those dll parameters and tags, if you replace all grid component with right namespace you will be able to run the project.)
Make sure there is no ambiguity. I am still trying to figure out why they removed GroupDataClass from .NET 4.0 in built toolkit. If it was there I was able to remove reference of wpf toolkit completely.
If most of the issues like this is solved I can push it in open source project soon.
Regards,
Bhushan Poojary
Apr 30, 2012 at 4:48 PM

Try this link:

http://chibnik.com/wp-content/uploads/2012/04/ExtGridTest.zip

Coordinator
Apr 30, 2012 at 8:10 PM

Thanks will get back to you within 12 hrs.

On Apr 30, 2012 9:18 PM, "RChibnik" <notifications@codeplex.com> wrote:

Coordinator
May 1, 2012 at 8:12 AM

Hi

 

It was very easy change just replace your column code this code (Code is working fine now). 

 <WpfToolkit:DataGrid.Columns>
                <ExtendedColumn:ExtendedDataGridTextColumn Header="Fund#" Binding="{Binding Path=fundNum}" AllowAutoFilter="True"/>
                <ExtendedColumn:ExtendedDataGridTextColumn Header="Security Name" Binding="{Binding Path=securityLongName}" Width="*" AllowAutoFilter="True"/>
                <ExtendedColumn:ExtendedDataGridTextColumn Header="SecId" Binding="{Binding Path=securityId}" Width="Auto" AllowAutoFilter="True"/>
                <ExtendedColumn:ExtendedDataGridTextColumn Header="Purchase" Binding="{Binding Path=purchaseDate}" Width="Auto" AllowAutoFilter="False"/>
                <ExtendedColumn:ExtendedDataGridTextColumn Header="ST/LT" Binding="{Binding Path=shortLongTerm}" Width="Auto" AllowAutoFilter="True"/>
                <ExtendedColumn:ExtendedDataGridTextColumn Header="Economic" Binding="{Binding Path=economicGainLoss}" Width="Auto" AllowAutoFilter="False"/>
 </WpfToolkit:DataGrid.Columns>

The reason you need to do that is becuase our extended datagrid inherits from wpftoolkit dll datagrid and it understands columns from those dll only or derived from it.

I am working on making .NET 4.0 dll which dosent require wpftoolkit.dll .

 

 

 

 

May 1, 2012 at 2:39 PM

Well, the filtering works. Unfortunately, its REALLY slow (slower than the non-working version I was using before.) Not sure if this is due to WPFToolkit, or the additional features.

Keep me posted on the 4.0 version - would be happy to test it.

Thanks for your help.

May 1, 2012 at 2:55 PM

Well, the filtering works. Unfortunately, its REALLY slow (slower than the non-working version I was using before.) Not sure if this is due to WPFToolkit, or the additional features.

Keep me posted on the 4.0 version - would be happy to test it.

Thanks for your help.

Jul 24, 2013 at 12:32 AM
Hello all,
I am new in wpf, I am trying to fill my extended datagrid from a bd using link to sql server. It works good but when I want to filter using the columns it gives me this error "system.argumentnullexception was unhandled". Could anybody help me please? Thanks !