C1DataGrid safe and load filterstate

Posted by: florian.weininger on 19 January 2021, 10:01 pm EST

    • Post Options:
    • Link

    Posted 19 January 2021, 10:01 pm EST

    Hello Support-Team,

    I updatet the C1DataGrid to the newest Version 2020v3.

    Now I’m facing a problem while saving and loading the filterstate of the columns.

    This worked in older versions without any problem.

    For saving the state I’m using the following Code. This works without an error.

     public override void SafeFilterState()
            {
                filteredColumns?.Clear();
    
                foreach (var filteredCol in dgPrototypes.FilteredColumns)
                {
                    try
                    {
                        filteredColumns.Add(filteredCol.Name, filteredCol.FilterState);
                    }
                    catch (Exception exc)
                    {
                        LogHandling.Logger.Error(exc);
                    }
                }
            }
    

    But Loading the filterstates with the following code leads to an error.

    I uploaded the complete Errormessage with this post.

    public override void LoadFilterState()
            {           
                List<DataGridColumnValue<DataGridFilterState>> filterList = new List<DataGridColumnValue<DataGridFilterState>>();
                try
                {
    
                    foreach (var filteredColumn in filteredColumns)
                    {
                        foreach (var datagridColumn in dgPrototypes.Columns)
                        {
                            if (datagridColumn.Name == filteredColumn.Key)
                            {
                                //filterList.Add(new KeyValuePair<C1.WPF.DataGrid.DataGridColumn, DataGridFilterState>(datagridColumn, filteredColumn.FilterState));
                                filterList.Add(new DataGridColumnValue<DataGridFilterState>(datagridColumn, filteredColumn.Value));
                            }
                        }
                    }
    
                    if (filterList.Count > 0)
                    {
                        dgPrototypes.FilterBy(filterList.ToArray());
                    }
                }
                catch (Exception exc)
                {
                    LogHandling.Logger.Error(exc);
                }
            }
    

    ErrorLoadingFilterState.zip

  • Posted 20 January 2021, 8:12 pm EST - Updated 3 October 2022, 11:45 pm EST

    Hi Florian,

    I am not able to reproduce this behavior at my end as saving/loading filter is working fine with the provided code. I have tested it with the build 4.5.20203.727. Please refer to the attached gif.

    I have also attached a sample for reference. (see DataGridFilterSave.zip)

    Could you please make the required changes in the attached sample in order to replicate the behavior.

    Regards,

    Kartik

    DataGridFilterSave.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels