Telerik Forums
UI for WPF Forum
1 answer
13 views

Hi Team,

   I followed the online documentation of RadPersistenceFramework to persist the selected fields of  RadPivotFieldList.   It doesn't work!  Here's my code.

 

--xmal

                <pivot:RadPivotFieldList x:Name="pfAttributes" Grid.Row="0" telerik:PersistenceManager.StorageId="pvFields"
                                     VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Width="250"
                                     DataProvider="{StaticResource DataProviderKeyMetrics}" />

--save layout

            IsolatedStorageProvider isoStorageProvider = new IsolatedStorageProvider();
            isoStorageProvider.SaveToStorage();

-- load layout

            IsolatedStorageProvider isoStorageProvider = new IsolatedStorageProvider();
            isoStorageProvider.LoadFromStorage();

 

            Thanks,

 

Martin Ivanov
Telerik team
 answered on 29 Jan 2024
1 answer
108 views

Hi,

I saw in other question that someday you will turn the UniqueName property into obsolete.

I need to save some configuration about the GridViewColumns to a file. I saw that when I use DataMemberBinding, the UniqueName name holds the Binding property name, but if I define a cell template without data member binding, the UniqueName property is null. How can I guarante the uniquenes of a column identifier? even if I put DataMemberBinding in all columns, theoretically I can have the same UniqueName name twice (binding two same property twice and showing different path in the cell template of the column).

 

It is not logical to call a property UniqueName without being unique. Can you help me please ??

How do you guarantee the uniqueness in your PersistenceManager implementation??

 

Martin Ivanov
Telerik team
 answered on 12 Sep 2022
0 answers
92 views

We have a strange issue that I've not seen posted or reported anywhere after two days of research

We have RadGridViews where we manage persistence using the Telerik PersistenceManager Class.

The grids are set as follows

    theGrid.ShowGroupPanel = false;
    theGrid.FilteringMode = Telerik.Windows.Controls.GridView.FilteringMode.FilterRow;
    theGrid.CanUserGroupColumns = false;
    theGrid.CanUserReorderColumns = true;

We gather data from a web service in the form of a data table and bind to the Grid.

When a filter is applied at the column level (for example a part number using the "Is Equal To"  filter) we save the grid stream, submit the query, retrieve the data, bind to the grid, Reload using the persistence manager.  

pseudo code

 

  • Gather Filter info
  • Save aStream
  • Get Data
  • Bind
  • PersistenceManager.Load(theGrid, astream);

The strange behavior is that I can consistently filter on a particular part number (String) and everything works as expected (A single result in the grid), but another part number results in a blank grid after calling the Manager.Load() code.  

In the second scenario, the underlying data table has one row, but it does not display in the grid.  If I comment out the code to load, then the value displays.  Using this, we lose the persistence, and can't "Clear filter" at the column level.

Long story short, the PersistenceManager.Load(theGrid, astream); seems to be failing, resulting in a blank Grid even though the underlying data table has one row.  Since this is Telerik code, we have no way to debug it.

 

Thanks in advance for any help.  I've attached a screen shot of the resulting grid, when the "Load" fails

John
Top achievements
Rank 1
 asked on 29 Jun 2022
3 answers
100 views

Hello

I have upgraded my version from 2019 R3 to 2020 R3 and have found that the GridView layouts saved in the old version will not longer load in the new version.

 

Here is my existing code:

string layout; // loaded from file
PersistenceManager manager = new PersistenceManager();
 byte[] byteArray = Encoding.ASCII.GetBytes(layout);
MemoryStream stream = new MemoryStream(byteArray);
manager.Load(this.RadGridView, stream);

 

When trying to load the layout it fails with:

Exception thrown: 'System.NullReferenceException' in Telerik.Windows.PersistenceFramework.dll Object reference not set to an instance of an object.

 

If have tried enabling AllowCrossVersion, but this then fails with:

Exception thrown: 'System.ArgumentOutOfRangeException' in mscorlib.dll

 

The only way I can get it to work is by following the recommendation in this post Here, it then loads as expected and without any errors:

PersistenceManager manager = new PersistenceManager();
 byte[] byteArray = Encoding.ASCII.GetBytes(this.layout.Replace("Version=2019.3.1023.45", "Version=2020.3.1020.45"));
MemoryStream stream = new MemoryStream(byteArray);
manager.Load(this.RadGridView, stream);

 

This isn't a satisfactory fix in the long run. Could you please advise how I should be handling this?

 

Thanks

Dave

Dinko | Tech Support Engineer
Telerik team
 answered on 10 Dec 2020
1 answer
196 views

We are using the PersistenceFramework to handle storing the user's settings in our application.  Currently the application consists of a single window that contains a RadWizard with three pages.  The first page gets the configuration options for the process, the second shows the progress of the operation, and the final page shows the results of the operation in a RadGridView.   We have worked around a few issues with the PersistenceFramework storing unwanted specific values (e.g. SelectedPage) by using SerializationOptions with the Except Condition.  Of course we used the Custom PropertiesProvider for the RadGridView.  This works in general; however, we have run into issues during development where, if you make a change in the XAML, (e.g. change the layout/presentation of the page) minor changes cause the saved properties to be incompatible and the application just crashes.  It then takes time to determine whether the problem is with the persistence or something the programmer did.

What we would like to do is go to the Condition="Only" model of persistence.  This would allow us to specify the few things like window size and position, configuration settings, and the final RadGridView properties; and persist just those.  I have successfully trimmed the main window data down to the window size and position using the Only Condition.   However, when trying to work with items deeper in the page. I haven't been able to filter properly.  I either get nothing, or everything.

I am looking for help on how persist the option from the first page and the RadGridView properties from the third page without the rest of the properties of either page or anything from the second page.

 

001.<base:Window x:Class="CatalogCompare.CatalogCompareView"
003.        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
004.        xmlns:base="clr-namespace:SSI.Base.UI;assembly=SSI.Base.UI"
005.        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
006.        xmlns:telerik1="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
007.        xmlns:persist="clr-namespace:SSI.Base.UI.Persistence;assembly=SSI.Base.UI"
008.        xmlns:radGridContextMenu="clr-namespace:SSI.Base.UI.Controls.RadGridContextMenu;assembly=SSI.Base.UI"
009.        xmlns:sys="clr-namespace:System;assembly=mscorlib"
010.        xmlns:behaviors="clr-namespace:CatalogCompare"
011.        Title="Catalog Compare"
012.        Height="440"
013.        Width="617"
014.        MinHeight="440"
015.        MinWidth="617"
016.        Icon="pack://application:,,,/SSI.Images;component/Images/CatalogCompare.ico">
017.    <telerik:PersistenceManager.SerializationOptions>
018.        <telerik:SerializationMetadataCollection>
019.            <telerik:PropertyNameMetadata Condition="Only" Expression="^\b(Top)\b$" SearchType="PropertyPath" />
020.            <telerik:PropertyNameMetadata Condition="Only" Expression="^\b(Left)\b$" SearchType="PropertyPath" />
021.            <telerik:PropertyNameMetadata Condition="Only" Expression="^\b(Width)\b$" SearchType="PropertyPath" />
022.            <telerik:PropertyNameMetadata Condition="Only" Expression="^\b(Height)\b$" SearchType="PropertyPath" />
023.        </telerik:SerializationMetadataCollection>
024.    </telerik:PersistenceManager.SerializationOptions>
025.    <Window.Resources>
026....
027.    </Window.Resources>
028.    <Grid x:Name="LayoutRoot">
029.        <telerik:RadWizard x:Name="wizard" Cancel="wizard_Cancel" Finish="wizard_Export" SelectedPageIndex="{Binding SelectedWizardPageIndex, Mode=TwoWay}" IsContentPreserved="True">
030.            <telerik:PersistenceManager.SerializationOptions>
031.                <telerik:SerializationMetadataCollection>
032.                    <telerik:PropertyNameMetadata Condition="Except" Expression="SelectedPage" SearchType="PropertyName" />
033.                </telerik:SerializationMetadataCollection>
034.            </telerik:PersistenceManager.SerializationOptions>
035.            <telerik:RadWizard.WizardPages>
036.                <telerik:WizardPage x:Name="configurePage" IsSideHeaderVisible="True" ButtonsVisibilityMode="Next,Cancel" NextButtonContent="Compare" IsTitleVisible="False" SideHeaderWidth="120" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" SideHeaderTemplate="{StaticResource sideHeaderTemplate}" HeaderTemplate="{StaticResource headerTemplate}" Template="{StaticResource WizardPageTemplate }" behaviors:CatalogComparePageBehavior.IsEnabled="True">
037.                    <Grid Margin="5">
038.                        <Grid.RowDefinitions>
039.                            <RowDefinition Height="Auto"/>
040.                            <RowDefinition Height="Auto"/>
041.                        </Grid.RowDefinitions>
042.                        <StackPanel>
043.                            <TextBlock Grid.Column="0" Text="Catalog Compare Options" FontSize="14" FontWeight="Bold"/>
044.                            <TextBlock Margin="10,10,0,0" Grid.Column="0" Text="Compare Type (Missing)" FontSize="12" FontWeight="DemiBold"/>
045.                            <RadioButton  Margin="10,5,0,0" GroupName="CompareType" Content="ID Only" IsChecked="{Binding GuidOnlyCompareType}"  ToolTip="Find catalog items by ID (GUID) only; catalog items with the same name but different IDs will show as missing"/>
046.                            <RadioButton Margin="10,5,0,0" GroupName="CompareType" Content="WorkShare Transfer/Project/Design" IsChecked="{Binding WorkShareCompareType}" ToolTip="Find catalog items with WorkShare matching if an ID (GUID) match is not found"/>
047.                        </StackPanel>
048.                    </Grid>
049.                </telerik:WizardPage>
050.                <telerik:WizardPage x:Name="progressPage" IsSideHeaderVisible="True" ButtonsVisibilityMode="Cancel" AllowNext="False" IsTitleVisible="False" SideHeaderWidth="120" SideHeaderTemplate="{StaticResource sideHeaderTemplate}"  HeaderTemplate="{StaticResource headerTemplate}" Template="{StaticResource WizardPageTemplate}" behaviors:CatalogComparePageBehavior.IsEnabled="True">
051.                    <Grid>
052.                        <Grid.ColumnDefinitions>
053.                            <ColumnDefinition Width="61"/>
054.                            <ColumnDefinition Width="350"/>
055.                        </Grid.ColumnDefinitions>
056.                        <StackPanel Margin="0,20,0,0"  Grid.Column="1">
057.                            <telerik:PersistenceManager.SerializationOptions>
058.                                <telerik:SerializationMetadataCollection>
059.                                    <telerik:PropertyNameMetadata Condition="Except" Expression="Children" SearchType="PropertyName" />
060.                                </telerik:SerializationMetadataCollection>
061.                            </telerik:PersistenceManager.SerializationOptions>
062.                            <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="Comparing Project Catalogs..."/>
063.                            <telerik:RadProgressBar Value="{Binding ProgressPercentage}"  Width="350" Minimum="0" Maximum="100" HorizontalAlignment="Left" VerticalAlignment="Center" Height="20" BorderThickness="2" BorderBrush="{StaticResource SSIGreyDark.Brush}" Foreground="{StaticResource SSIBlueDark.Brush}" />
064.                            <TextBlock Text="{Binding ProgressText}" VerticalAlignment="Center" HorizontalAlignment="Center" />
065.                        </StackPanel>
066.                    </Grid>
067.                </telerik:WizardPage>
068.                <telerik:CompletionWizardPage x:Name="resultsPage" IsSideHeaderVisible="True" ButtonsVisibilityMode="Finish,Cancel" IsTitleVisible="False" AllowFinish="{Binding ShowResultsGrid}" FinishButtonContent="Export" CancelButtonContent="Close" SideHeaderWidth="120" SideHeaderTemplate="{StaticResource sideHeaderTemplate}"  HeaderTemplate="{StaticResource headerTemplate}" Template="{StaticResource WizardPageTemplate}"  behaviors:CatalogComparePageBehavior.IsEnabled="True">
069.                    <telerik:PersistenceManager.SerializationOptions>
070.                        <telerik:SerializationMetadataCollection>
071.                            <telerik:PropertyNameMetadata Condition="Except" Expression="AllowFinish" SearchType="PropertyName" />
072.                        </telerik:SerializationMetadataCollection>
073.                    </telerik:PersistenceManager.SerializationOptions>
074.                    <Grid>
075.                        <TextBlock  Text="No catalog differences detected" FontSize="16" FontWeight="DemiBold" Margin="10,20,0,0" HorizontalAlignment="Left" Visibility="{Binding ShowNoCatalogChanges, Converter={StaticResource BooleanToVisibilityConverter}}">
076.                            <telerik:PersistenceManager.SerializationOptions>
077.                                <telerik:SerializationMetadataCollection>
078.                                    <telerik:PropertyNameMetadata Condition="Except" Expression="Visibility" SearchType="PropertyName" />
079.                                </telerik:SerializationMetadataCollection>
080.                            </telerik:PersistenceManager.SerializationOptions>
081.                        </TextBlock>
082.                        <base:BaseRadGridView Name="_grid"
083.                            GroupRenderMode="Flat"
084.                            AutoGenerateColumns="False"
085.                            ItemsSource="{Binding CatalogEntryList}"
086.                            Grouping="GridGrouping"
087.                            AutoExpandGroups="False"
088.                            persist:Persist.PersistColumnGroups="True"
089.                            persist:Persist.PersistColumnSorting="True"
090.                            ShowGroupPanel="True"
091.                            Margin="-3,-3,-3,-3"
092.                            AlternateRowBackground="#FFF4F4F4"
093.                            AlternationCount="2"
094.                            Visibility="{Binding ShowResultsGrid, Converter={StaticResource BooleanToVisibilityConverter}}">
095.                            <telerik:RadContextMenu.ContextMenu>
096.                                <radGridContextMenu:RadGridContextMenu x:Name="_contextMenu" ExportOptionIsVisible="False"  />
097.                            </telerik:RadContextMenu.ContextMenu>
098.                            <telerik:RadGridView.Columns>
099.                                <telerik:GridViewDataColumn DataMemberBinding="{Binding DatasetCategory}"
100.                                                Header="Category"
101.                                                ShowColumnWhenGrouped="True"
102.                                                DisplayIndex="0"
103.                                                ShowToolTipOnTrimmedText="True"
104.                                                UniqueName="Category"
105.                                                Width="100"/>
106....
107.                            </telerik:RadGridView.Columns>
108.                        </base:BaseRadGridView>
109.                    </Grid>
110.                </telerik:CompletionWizardPage>
111.            </telerik:RadWizard.WizardPages>
112.        </telerik:RadWizard>
113.    </Grid>
114.</base:Window>
Martin Ivanov
Telerik team
 answered on 16 Jan 2020
8 answers
391 views

Hi,

I'm facing one issue and I really do not know where could the problem.

 

It's once again (as I read few other posts in the forum, nothing new) related to persisting order of columns in GridView. My problem happens only when the columns get reordered by drag-n-drop. When I add and or remove columns (this is done programatically in my view's code-behind) and try to persists Grid's state, everything works well. Unless I reorder their sequence.

 

 

It's worth mentioning that I'm persisting the state in my filesystem so that I could restore it later. Solution with IsolatedStorageProvider is not well suited for me. But I do not think that this should be any issue.Storage happens everytime the button 'Save layout' is being clicked.

 

I have created sample video that shows what I'm trying to say maybe even more expressively. Look here.I have created sample video that shows what I'm trying to say maybe even more expressively. Look here - https://drive.google.com/file/d/0B0cxhvgqPibkNHhyUzM1TVVHOVU/view

 

I have implemented my version of ICustomPropertyProvider, but it's almost identical to the one provided in WPF Control Examples. See here:

 

public class GridViewCustomPropertyProvider : ICustomPropertyProvider
    {

        private const string _columnsProperty = "Columns";
        private const string _sortDescriptorsProperty = "SortDescriptors";

        public CustomPropertyInfo[] GetCustomProperties()
        {
            return new CustomPropertyInfo[]
            {
                new CustomPropertyInfo(_columnsProperty, typeof(List<ColumnProxy>)), 
                new CustomPropertyInfo(_sortDescriptorsProperty, typeof(List<SortDescriptorProxy>)), 
            };
        }

        public void InitializeObject(object context)
        {
            if (context is RadGridView)
            {
                RadGridView gridView = context as RadGridView;
                //gridView.Columns.Clear();
                gridView.SortDescriptors.Clear();
                foreach (GridViewColumn gridViewColumn in gridView.Columns)
                {
                    gridViewColumn.ClearFilters();
                }
            }
        }

        public object InitializeValue(CustomPropertyInfo customPropertyInfo, object context)
        {
            return null;
        }

        public void RestoreValue(CustomPropertyInfo customPropertyInfo, object context, object value)
        {
            RadGridView gridView = context as RadGridView;

            switch (customPropertyInfo.Name)
            {
                case _sortDescriptorsProperty:

                    gridView.SortDescriptors.SuspendNotifications();
                    gridView.SortDescriptors.Clear();

                    List<SortDescriptorProxy> proxies = value as List<SortDescriptorProxy>;

                    foreach (SortDescriptorProxy proxy in proxies)
                    {
                        GridViewColumn column = gridView.Columns[proxy.ColumnName];
                        gridView.SortDescriptors.Add(new ColumnSortDescriptor(){Column = column, SortDirection = proxy.SortDirection});
                    }

                    gridView.SortDescriptors.ResumeNotifications();

                    break;

                default:

                    var columnProxies = value as List<ColumnProxy>;
                    //var orderedColumns = columnProxies.OrderBy(x => x.DisplayIndex);

                    foreach (ColumnProxy columnProxy in columnProxies)
                    {
                        GridViewColumn gridColumn = gridView.Columns[columnProxy.UniqueName];
                        gridColumn.DisplayIndex = columnProxy.DisplayIndex;
                        gridColumn.Header = "blabhalbl" + columnProxy.Header;
                        gridColumn.Width = columnProxy.Width;
                        //gridView.Columns.Add(gridColumn);
                    }

                    break;
            }
        }

        public object ProvideValue(CustomPropertyInfo customPropertyInfo, object context)
        {
            RadGridView gridView = context as RadGridView;

            var orderedColuns = OrderedColumns(gridView);

            switch (customPropertyInfo.Name)
            {

                case _sortDescriptorsProperty:
                    {
                        List<SortDescriptorProxy> sortDescriptorProxies = new List<SortDescriptorProxy>();

                        foreach (ColumnSortDescriptor descriptor in gridView.SortDescriptors)
                        {
                            sortDescriptorProxies.Add(new SortDescriptorProxy()
                            {
                                ColumnName = descriptor.Column.UniqueName,
                                SortDirection = descriptor.SortDirection,
                            });
                        }

                        return sortDescriptorProxies;
                    }


                default:

                    var columns = new List<ColumnProxy>();
                    foreach (GridViewColumn column in orderedColuns.OrderBy(x => x.DisplayIndex))
                    {
                        columns.Add(new ColumnProxy()
                        {
                            UniqueName = column.UniqueName,
                            Header = column.Header.ToString() + "someother",
                            DisplayIndex = column.DisplayIndex,
                            Width = column.Width
                        });
                    }

                    return columns;
            }
        }

        private static List<GridViewColumn> OrderedColumns(RadGridView gridView)
        {
            var orderedList = new List<GridViewColumn>();

            for (int i = 0; i < gridView.Columns.Count; i++)
            {
                orderedList.Add(gridView.Columns[i]);
            }
            return orderedList;
        }
    }

 

Thanks in advance for any piece of advice,

Erik

Hans
Top achievements
Rank 1
Veteran
 answered on 25 Nov 2019
3 answers
301 views

Hello,

I'm trying to exclude some (but not all) RadGridView columns' information from being persisted using PersistenceManager.

For example, in the below grid, how would I exclude column Info's properties from being persisted based on the column's Header name (assume I've defined CustomPropertyProvider for the grid to persist properties like Width, Header, etc.)?

<telerik:RadGridView x:Name="TestGrid"
                     telerik:PersistenceManager.StorageId="TestGrid"
                     AutoGenerateColumns="False">
   <telerik:RadGridView.Columns>
      <telerik:GridViewDataColumn Header="Info" DataMemberBinding="{Binding Info}"/>
      <telerik:GridViewDataColumn Header="Data" DataMemberBinding="{Binding Data}"/>
   </telerik:RadGridView.Columns>
</telerik:RadGridView>

 

I could use SerializationOptions but I'm not sure what I'd put in the "Expression" field to exclude column "Info" (see below):
<telerik:PersistenceManager.SerializationOptions>
   <telerik:SerializationMetadataCollection>
      <telerik:PropertyNameMetadata Condition="Except" Expression="??" SearchType="PropertyName" />
   </telerik:SerializationMetadataCollection>
</telerik:PersistenceManager.SerializationOptions>

 

Drago
Telerik team
 answered on 13 Aug 2019
3 answers
32 views

Hello,

I'm using IsolatedStorageProvider to save/load RadGridView settings in my application and I also wanted to provide the ability to serialize/deserialize settings when the application gets updated to a newer version of Telerik controls. If I were to use PersistenceManager, this would be possible via PersistenceManager.AllowCrossVersion property, but I cannot find anything similar when using IsolatedStorageProvider.

How can assembly upgrades be handled with IsolatedStorageProvider?

Martin Ivanov
Telerik team
 answered on 29 Jul 2019
0 answers
12 views

Hello team,

When I added a new column , the load fails. The error message in the output window is  'System.NullReferenceException'.

Thanks,

Peter

 

Peter
Top achievements
Rank 1
 asked on 14 Feb 2019
1 answer
44 views

While saving the filter descriptors of the gridview (i.e. serializing the gridview to an xml using the PersistentManager.Save(radgridview)), the persistent manager is unable to save the value of the distinct filter value of type DateTimeOffset. 

Here is the part of xml serialization of the SelectedDistinctValues of FilterDescriptors with type DateTimeOffset on radgridview.

 <PV Key="254" TypeKey="-933998283">     

<Value xsi:type="DateTimeOffset" />   

</PV> 

which should Ideally be as follows:

 <PV Key="254" TypeKey="-933998283">     
<Value xsi:type="DateTimeOffset"> 12/8/2018 11:25:59 AM +00:00 </Value>   
</PV> 

This issue is observed on 2017.2.614.45 version.

Can you please provide your insights and resolve this issue?

Martin Ivanov
Telerik team
 answered on 07 Jan 2019
Narrow your results
Selected tags
Tags
+? more
Top users last month
horváth
Top achievements
Rank 2
Iron
Iron
Steve
Top achievements
Rank 2
Iron
Erkki
Top achievements
Rank 1
Iron
Mark
Top achievements
Rank 2
Iron
Iron
Veteran
Jakub
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
horváth
Top achievements
Rank 2
Iron
Iron
Steve
Top achievements
Rank 2
Iron
Erkki
Top achievements
Rank 1
Iron
Mark
Top achievements
Rank 2
Iron
Iron
Veteran
Jakub
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?