Save in each user session

10 posts, 0 answers
  1. danparker276
    danparker276 avatar
    389 posts
    Member since:
    Aug 2010

    Posted 31 Jul 2013 Link to this post

    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).
  2. Nils C.
    Nils C. avatar
    41 posts
    Member since:
    Oct 2009

    Posted 01 Aug 2013 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. danparker276
    danparker276 avatar
    389 posts
    Member since:
    Aug 2010

    Posted 01 Aug 2013 Link to this post

    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?
  5. Nils C.
    Nils C. avatar
    41 posts
    Member since:
    Oct 2009

    Posted 01 Aug 2013 Link to this post

    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 
  6. danparker276
    danparker276 avatar
    389 posts
    Member since:
    Aug 2010

    Posted 01 Aug 2013 Link to this post

    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();


  7. Angel Petrov
    Admin
    Angel Petrov avatar
    1006 posts

    Posted 05 Aug 2013 Link to this post

    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.
  8. danparker276
    danparker276 avatar
    389 posts
    Member since:
    Aug 2010

    Posted 05 Aug 2013 Link to this post

    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.
  9. Angel Petrov
    Admin
    Angel Petrov avatar
    1006 posts

    Posted 08 Aug 2013 Link to this post

    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.
  10. danparker276
    danparker276 avatar
    389 posts
    Member since:
    Aug 2010

    Posted 09 Aug 2013 Link to this post

    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.
  11. Angel Petrov
    Admin
    Angel Petrov avatar
    1006 posts

    Posted 14 Aug 2013 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017