This is a migrated thread and some comments may be shown as answers.

Automatic loading of persisted settings

1 Answer 69 Views
PersistenceFramework
This is a migrated thread and some comments may be shown as answers.
Ásgeir
Top achievements
Rank 1
Ásgeir asked on 15 Mar 2012, 12:22 PM
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.

1 Answer, 1 is accepted

Sort by
0
Alex Fidanov
Telerik team
answered on 19 Mar 2012, 09:15 AM
Hello,

 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 >>
Tags
PersistenceFramework
Asked by
Ásgeir
Top achievements
Rank 1
Answers by
Alex Fidanov
Telerik team
Share this question
or