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

Save in each user session

9 Answers 303 Views
Persistence Framework
This is a migrated thread and some comments may be shown as answers.
danparker276
Top achievements
Rank 2
danparker276 asked on 01 Aug 2013, 01:28 AM
I see where you set cookies to set the storage location:
RadPersistenceManager1.StorageProviderKey = CookieName;
  RadPersistenceManager1.StorageProvider = new CookieStorageProvider(CookieName);
But I just want to keep it for that user session.  I don't want to store it.  I tried enabling the view state, but that didn't seem to do anything

Right now it saves it for all users, so when someone applies a filter everyone gets it and people are wondering where the data is. On top of that, the radgrid doesn't indicate that there's a filter (I'm on the metro theme).

9 Answers, 1 is accepted

Sort by
0
Nils C.
Top achievements
Rank 1
answered on 01 Aug 2013, 11:21 AM
Hi dan,

thats quite an easy task, just implement your own Storageprovider like shown here: http://demos.telerik.com/aspnet-ajax/persistence-framework/examples/custom-storage-provider/defaultcs.aspx . The storage provider can store the data in the session and the session will be gone after the session ends.

I did it myself for persisting in our database and it took around a few minutes.

Best

Nils
0
danparker276
Top achievements
Rank 2
answered on 01 Aug 2013, 04:58 PM
Maybe I'm missing something, but that demo doesn't even work for me or work that well.

I do the following steps:
1. Sort the product name column.
2. Click Save State.
3. Click Reset Stored State.
4. Click Load State.

Why is the product column still sorted after this?  How can I clear the filters?
0
Nils C.
Top achievements
Rank 1
answered on 01 Aug 2013, 05:09 PM
Hi ,

after the reset, no rebind is called. If a rebind would be called, the filter is cleared again. Your step 4 (load state) does nothing, cause there is no state anymore after the reset.

So to clear you should:

1. Reset the stored state
2. Call rebind for the grid

Best 
0
danparker276
Top achievements
Rank 2
answered on 01 Aug 2013, 06:01 PM
I'm basically calling this in the page_init of the masterPage,  and I'm saving and loading it every page load which isn't a postback.
Every new session, I'm still getting my saved results.  Shouldn't this clear my results:  Does rpmMaster.Controls.Clear(); Clear things?




protected void Page_Init(object sender, EventArgs e)
{
 
 
 
    txtMainError.Text = "";
    if (Session["cSeason"] == null){
 
        rpmMaster.StorageProviderKey = CookieName;
        rpmMaster.StorageProvider = new CookieStorageProvider(CookieName);
 
 
        Response.Cookies[CookieName].Expires = DateTime.Now.AddDays(-1);
        rpmMaster.Controls.Clear();
        rpmMaster.SaveState();
        rpmMaster.LoadState();


0
Angel Petrov
Telerik team
answered on 05 Aug 2013, 03:05 PM
Hello Dan,

I am not quite sure that I fully understand the scenario. Could you please provide a detail explanation on what are the exact requirements? It would be best to also provide us with the markup and code-behind of the page. This would be of great help as we will be able to get a better understanding of the problem.

Regards,
Angel Petrov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
danparker276
Top achievements
Rank 2
answered on 05 Aug 2013, 05:09 PM
Basically I have an LOB application with a lot of grids.
When user A logs into the website, there should be no filters on any of the grids.
When user A sets filters or sorting on grids during that session, they should persist.
When user A exits and logs back in, there should be no filters on any of the grids.

When user B logs in, there should be no filters on the grids, no matter what user A is doing.

I don't care if I store it in the cookie or the user session.  I guess I'd prefer the user session, but a cookie is fine.
0
Angel Petrov
Telerik team
answered on 08 Aug 2013, 02:08 PM
Hello,

One way for achieving this is storing the settings in the database individually for every user. To distinguish which setting should be loaded you will additionally need to store the SessionID and UserID. Please note that this requirements is not related to RadControls for ASP.NET AJAX and it is a developers responsibility to handle such cases.

Regards,
Angel Petrov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
danparker276
Top achievements
Rank 2
answered on 09 Aug 2013, 08:58 PM
I don't mind if I have to keep it as a cookie.  I just want to be able to clear it every new session.  I guess what I'll do is delete the cookie every the program starts up:
            HttpCookie myCookie = new HttpCookie(CookieName);
            myCookie.Expires = DateTime.Now.AddDays(-1d);
            Response.Cookies.Add(myCookie);
            rpmMaster.StorageProviderKey = CookieName;
            rpmMaster.StorageProvider = new CookieStorageProvider(CookieName);

I'm not sure what the advantage would be of keeping it the same for everyone.  If user A sorts it one way, would would user B care what user A did.  So keeping it as a cookie would work for me.  It would be nice if it just stored it in the user session.
The other thing is that I can't tell when I grid is filtered or not.  The filtered text doesn't show up in the search boxes like on the demo.
0
Angel Petrov
Telerik team
answered on 14 Aug 2013, 03:33 PM
Hello Dan,

If the filtered value does not show up in the filter text box this means that the restoring of the setting was unsuccessful. Note that after the settings are loaded you should Rebind the grid in order to correctly apply them.

Regards,
Angel Petrov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Persistence Framework
Asked by
danparker276
Top achievements
Rank 2
Answers by
Nils C.
Top achievements
Rank 1
danparker276
Top achievements
Rank 2
Angel Petrov
Telerik team
Share this question
or