How To Save and load settings with RadGridView for Silverlight?

50 posts, 0 answers
  1. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 01 Jun 2010 Link to this post

    Hello david mcintyre,

    I have tried to reproduce your problem but everything works fine on my side. Please, find attached a sample project and in case there is something I am missing to match your requirements, do not hesitate to get back to us.

     

    All the best,
    Maya
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  2. david mcintyre
    david mcintyre avatar
    31 posts
    Member since:
    Mar 2010

    Posted 08 Jun 2010 Link to this post

    i was experiencing this issue w/ the trial DLLs (RadControls for Silverlight Q1 2010 SP1).  when we purchased the DLLs (RadControls for SL 4 2010 1 0603 DEV hotfix) it worked fine. 
  3. DevCraft banner
  4. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 09 Jun 2010 Link to this post

    Hello david mcintyre,

     
    The sample project I have sent to you is also using Trial version of our binaries but from our latest internal build, so most probably the issues you encountered had already been fixed. However, the most important thing is that now everything is working fine on your side too.

    Greetings,
    Maya
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  5. Marlos
    Marlos avatar
    13 posts
    Member since:
    Jul 2010

    Posted 27 Jul 2010 Link to this post

    Would like to save the layout of the grid view that contains columns of type 
    GridViewCheckBoxColumn and GridViewComboBoxColumn?
  6. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 28 Jul 2010 Link to this post

    Hello,

    I believe that the approach used in our demo will work no matter of column types used in the grid. 

    Kind regards,
    Vlad
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Pandit Prerna
    Pandit Prerna avatar
    14 posts
    Member since:
    Dec 2009

    Posted 02 Aug 2010 Link to this post

    I used the sample to save the settings and found out that none of the cell templates is being persisted to isolated storage. I have defined few cell templates in my xaml file. Please let me know how to persist them.

  8. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 03 Aug 2010 Link to this post

    Hi,

     I'm afraid that you cannot persist templates. 

    Greetings,
    Vlad
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. Pandit Prerna
    Pandit Prerna avatar
    14 posts
    Member since:
    Dec 2009

    Posted 03 Aug 2010 Link to this post

    Hi Vald,

    Could I maybe add templates at runtime once I know what the columns are, just as a workaround.

    I just would like to use the save/reload feature if possiblke.
  10. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 03 Aug 2010 Link to this post

    Hello,

     You can plug the cell templates in this code:

    foreach (ColumnSetting setting in Settings.ColumnSettings)
                        {
                            ColumnSetting currentSetting = setting;
     
                            GridViewDataColumn column = (from c in grid.Columns.OfType<GridViewDataColumn>()
                                                         where c.UniqueName == currentSetting.UniqueName
                                                         select c).FirstOrDefault();
     
                            if (column != null)
                            {
                                if (currentSetting.DisplayIndex != null)
                                {
                                    column.DisplayIndex = currentSetting.DisplayIndex.Value;
                                }
     
                                if (setting.Width != null)
                                {
                                    column.Width = new GridViewLength(setting.Width.Value);
                                }
                            }
                        }

    Kind regards,
    Vlad
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. Pandit Prerna
    Pandit Prerna avatar
    14 posts
    Member since:
    Dec 2009

    Posted 03 Aug 2010 Link to this post

    Could you please refer me to a sample code that adds templates at runtime? It will be much appreciated.

    Thanks
  12. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 04 Aug 2010 Link to this post

    Hello,

     Indeed the code I've posted is part of RadGridViewSettings class from our demo. You can use it to plug your own logic like loading of templates.

    Sincerely yours,
    Vlad
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  13. Bryan Johnson
    Bryan Johnson avatar
    18 posts
    Member since:
    May 2010

    Posted 26 Oct 2010 Link to this post

    I am also having a problem with saving/loading settings for radgridview when the grid contains check box columns.  The save/load works fine otherwise.  After putting in some breakpoints in the RadGridViewSettings.cs file I found the problem was occuring during the 'get' of the PropertySetting class when the column being processed was a check box column:

    public class PropertySetting
    {
        string _PropertyName;
        public string PropertyName
        {
            get
            {
                return _PropertyName;
            }
            set
            {
                _PropertyName = value;
            }
        }
    }

    The error is caught in the 'catch' section of this try/catch block:

    if (grid.Columns != null)
    {
        try
        {
            Settings.ColumnSettings.Clear();
            foreach (GridViewColumn column in grid.Columns)
            {
                if (column is GridViewDataColumn)
                {
                    GridViewDataColumn dataColumn = (GridViewDataColumn)column;
                    ColumnSetting setting = new ColumnSetting();
                    setting.PropertyName = dataColumn.DataMemberBinding.Path.Path;
                    setting.UniqueName = dataColumn.UniqueName;
                    setting.Header = dataColumn.Header;
                    setting.Width = dataColumn.ActualWidth;
                    setting.DisplayIndex = dataColumn.DisplayIndex;
                    setting.IsVisible = dataColumn.IsVisible;
                    Settings.ColumnSettings.Add(setting);
                }
            }
        }
        catch
        {
            //
        }
    }

    The error is as follows:

    Type 'System.Windows.UIElement' cannot be serialized. Consider marking it with the DataContractAttribute
    attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute.
    Alternatively, you can ensure that the type is public and has a parameterless constructor - all public
    members of the type will then be serialized, and no attributes will be required.

    Here is the gridview defintion xaml code:

        <telerikGridView:RadGridView x:Name="CommissiondataGrid" Margin="8,75,8,8" ShowGroupPanel="False" ItemsSource="{Binding CommissionList}" AutoGenerateColumns="False"  
                                     DataLoadMode="Asynchronous" Deleting="CommissiondataGrid_Deleting" RowEditEnded="CommissiondataGrid_RowEditEnded" AddingNewDataItem="CommissiondataGrid_AddingNewDataItem"
                                     ShowInsertRow="True" RowValidating="CommissiondataGrid_RowValidating" ActionOnLostFocus="None" CanUserInsertRows="False" SelectionChanged="CommissiondataGrid_SelectionChanged" MouseLeave="CommissiondataGrid_MouseLeave">
            <telerik:RadGridView.GroupRowStyle>
              <Style TargetType="telerik:GridViewGroupRow">
                  <Setter Property="ShowHeaderAggregates" Value="False" />
              </Style>
            </telerik:RadGridView.GroupRowStyle>
            <telerikGridView:RadGridView.Columns>
                <telerikGridView:GridViewDataColumn DataMemberBinding="{Binding CommissionSeq}" Header="Seq#"/>
                <telerikGridView:GridViewDataColumn DataMemberBinding="{Binding PartCategory, Converter={StaticResource UpperConverter}, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" Header="Part Category"/>
                <telerikGridView:GridViewCheckBoxColumn DataMemberBinding="{Binding PartRepaired, Mode=TwoWay}">
                    <telerikGridView:GridViewCheckBoxColumn.Header>
                        <TextBlock Text="Commission for Repaired Parts" TextWrapping="Wrap" />
                    </telerikGridView:GridViewCheckBoxColumn.Header>
                </telerikGridView:GridViewCheckBoxColumn>
                <telerikGridView:GridViewDataColumn DataMemberBinding="{Binding RangeStart, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" Header="Range Start" TextAlignment="Right" DataFormatString="{}{0:n2}"/>
                <telerikGridView:GridViewDataColumn DataMemberBinding="{Binding RangeEnd, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" Header="Range End" TextAlignment="Right" DataFormatString="{}{0:n2}"/>
                <telerikGridView:GridViewDataColumn DataMemberBinding="{Binding CommissionPct, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" TextAlignment="Right" DataFormatString="{}{0:P2}">
                    <telerikGridView:GridViewDataColumn.Header>
                        <TextBlock Text="Commission Percentage" TextWrapping="Wrap" />
                    </telerikGridView:GridViewDataColumn.Header>
                </telerikGridView:GridViewDataColumn>
                <telerikGridView:GridViewCheckBoxColumn DataMemberBinding="{Binding GrossNet, Mode=TwoWay}">
                    <telerikGridView:GridViewCheckBoxColumn.Header>
                        <TextBlock Text="Gross Amt (Checked) Net Amount (Unchecked)" TextWrapping="Wrap" />
                    </telerikGridView:GridViewCheckBoxColumn.Header>
                </telerikGridView:GridViewCheckBoxColumn>
            </telerikGridView:RadGridView.Columns>
        </telerikGridView:RadGridView>

    So far I have not found a solution around this problem.  Has anybody experienced the same issue?

    Thanks,
    Bryan





  14. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 28 Oct 2010 Link to this post

    Hi Bryan,

     The issue most probably was caused by the Header property of the check box column (CheckBox in case of multiple selection) . You can remove save/load of the Header for this column type conditionally. 

    Best wishes,
    Vlad
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  15. preeti
    preeti avatar
    36 posts
    Member since:
    Oct 2010

    Posted 02 Nov 2010 Link to this post

    hi milan,

    i am trying to use ure code for saving my radgridview collums order..
    However i am using telerik silverlight grid of older version  2010.1.309.1030.
    When i replace your dlls with my version dlls then the collumn ordering does not work.
    Is there any alternate way in the previous version to achieve the same.
    just change to old dlls check with your code the collumn reordering will not work.


    Do let me know asap.
  16. Timothy
    Timothy avatar
    75 posts
    Member since:
    Oct 2010

    Posted 07 Apr 2011 Link to this post

    I am recieving this error when I run the project?

    Operation not permitted on IsolatedStorageFileStream.
  17. loraine
    loraine avatar
    30 posts
    Member since:
    Apr 2011

    Posted 31 May 2011 Link to this post

    hi!

    there was an error on the onunload part. can you please post a sample application that saves the gridview settings for silverlight 4? thanks :)

    Regards,
    Loraine
  18. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 01 Jun 2011 Link to this post

    Hello Loraine,

    Generally, you may run through our demos for getting the latest version of the Save and Load RadGridView Settings example. Furthermore, you may execute your own version of the examples in order to test it locally.
    Let me know if you encounter any other difficulties and you need an assistance.

    Greetings,
    Maya
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  19. Evan
    Evan avatar
    2 posts
    Member since:
    Sep 2011

    Posted 12 Nov 2011 Link to this post

    I am anxious to try the load and save but none seem compatible with the current version 2011.2.712.1040 particularly in the area of sort descriptors. And of course pushing the link for "demo" takes me to an empty page.
  20. Evan
    Evan avatar
    2 posts
    Member since:
    Sep 2011

    Posted 12 Nov 2011 Link to this post

    I am anxious to try the load and save but none seem compatible with the current version 2011.2.712.1040 particularly in the area of sort descriptors. And of course pushing the link for "demo" takes me to an empty page.
  21. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 14 Nov 2011 Link to this post

    Hi Evan,

    Actually, the recommended approach now is to work with our RadPersistenceFramework to save and load the settings of RadGridView. Please take a look at this demo for a reference.
    Let us know if you need any further assistance with it.
     

    Greetings,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top
DevCraft banner