Automatic loading of persisted settings

2 posts, 0 answers
  1. Ásgeir
    Ásgeir avatar
    2 posts
    Member since:
    Nov 2011

    Posted 15 Mar 2012 Link to this post

    I'm using the code from 2011 Q3 SP1 for persisting the RadGridView.
    I want the persisting to be automatic, load when the user enters the page and save changes when leaving.
    There seems to be a problem with timing. I've been switching between the navigation events, page loaded event and grid loaded event.
    Now I've ended up with calling provider.LoadFromStorage() on the grid_loaded event and provider.SaveToStorage() on the OnNavigatingFrom event.

    This seems to work most of the time but sometimes not. If I switch between two pages (with one being persisted) it sometimes works but sometimes i get an exception, caused by the proxy.DisplayOrder being -1 in the following line:
    column.DisplayIndex = proxy.DisplayOrder;
    As I'm looping through the columns I should get 0,1,2,3,.... but sometimes it's -1,-1,-1,-1,....

    Is it a problem with where I'm putting the code to load and save changes?
    Has this been fixed in the 2012 Q1 demo?

    I tried changing it to check if the Displayorder is >= 0 before the line above but then i get some other similar error.
  2. Alex Fidanov
    Alex Fidanov avatar
    636 posts

    Posted 19 Mar 2012 Link to this post


     You are right - this is a timing issue. It could be that the GridView's columns have not yet loaded.

    The other exception that you are getting is because two columns have the same DisplayIndex, which throws the exception. 

    I would recommend checking if the DisplayIndex is not -1 and saving it. If it is a -1, then pick an unique index that is not already taken. 

    Please let me know if that is acceptable in your scenario.

    Kind regards,
    Alex Fidanov
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. DevCraft R3 2016 release webinar banner
Back to Top