Save and load user selections

6 posts, 0 answers
  1. Kalyani
    Kalyani avatar
    20 posts
    Member since:
    Jul 2011

    Posted 24 Apr 2014 Link to this post

    Hello,

    I am trying to save user preference and load them back again.  I did check this (http://demos.telerik.com/aspnet-ajax/pivotgrid/examples/applicationscenarios/persisting-radpivotgrid-settings/defaultcs.aspx) demo for it and created a test page but I am not able to load a saved state.  So I am able to save a state but after I reset the state I am not able to load it again.  I am missing something but am not sure what it is.  Can you please help me.


    My aspx page

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="TelerikPersistance.aspx.cs" Inherits="Test_TelerikPersistance"  %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">    
        <asp:Label ID="lst" runat ="server" Text ="test"/>
        <tlrk:RadScriptManager runat="server" ID="RadScriptManager1" />
        <tlrk:RadPersistenceManager runat="server" ID="RadPersistenceManager1">
            <PersistenceSettings>
                <tlrk:PersistenceSetting ControlID="RadPivotGrid1" />
            </PersistenceSettings>
        </tlrk:RadPersistenceManager>
        <tlrk:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"></tlrk:RadAjaxLoadingPanel>
        <tlrk:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1">
            <tlrk:RadButton ID="SaveButton" runat="server" Text="Save state" OnClick="SaveButton_Click"  AutoPostBack="true"/>
            <tlrk:RadButton ID="ResetButton" runat="server" Text="Reset stored state" OnClick="ResetButton_Click"  AutoPostBack="true"/>
            <tlrk:RadButton ID="LoadButton" runat="server" Text="Load state" OnClick="LoadButton_Click"  AutoPostBack="true"/>
            <tlrk:RadPivotGrid ID="RadPivotGrid1" runat="server" AllowFiltering="true"
                AllowPaging="true" PageSize="12" ShowFilterHeaderZone="false" AllowSorting="true" EnableConfigurationPanel="true">           
                <ConfigurationPanelSettings Position="Left" DefaultDeferedLayoutUpdate="true" />
            </tlrk:RadPivotGrid>
        </tlrk:RadAjaxPanel>
        </form>
    </body>
    </html>



    My C# code

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.Configuration;
    using System.Configuration;

    public partial class Test_TelerikPersistance : System.Web.UI.Page
    {
     protected void Page_Load(object sender, System.EventArgs e)
     {
      if (!IsPostBack)
      {
       string s = null;
       if (WebConfigurationManager.ConnectionStrings["XXXXXX"] != null)
        s = WebConfigurationManager.ConnectionStrings["XXXXXX"].ConnectionString;
       string cubeName = ConfigurationManager.AppSettings["LaborCubeName"];
       RadPivotGrid1.OlapSettings.ProviderType = Telerik.Web.UI.PivotGridOlapProviderType.Adomd;
       RadPivotGrid1.OlapSettings.AdomdConnectionSettings.ConnectionString = s;
       RadPivotGrid1.OlapSettings.AdomdConnectionSettings.Cube = cubeName;
      }
      if (!IsPostBack && Object.Equals(Session["CustomPersistenceSettingsKey"], null))
      {
       LoadButton.Enabled = false;
       lst.Text = "in page load ";
      }
     }

     protected void SaveButton_Click(object sender, EventArgs e)
     {
      Session["CustomPersistenceSettingsKey"] = this.Session.SessionID;
      string fileId = Session["CustomPersistenceSettingsKey"].ToString();
      lst.Text = fileId;
      LoadButton.Enabled = true;
      RadPersistenceManager1.StorageProviderKey = fileId;
      RadPersistenceManager1.SaveState();
     }

     protected void ResetButton_Click(object sender, EventArgs e)
     {
      Response.Redirect(Request.Url.ToString());
     }

     protected void LoadButton_Click(object sender, EventArgs e)
     {
      string fileId = Session["CustomPersistenceSettingsKey"].ToString();
      RadPersistenceManager1.StorageProviderKey = fileId;
      lst.Text = " Load btn " + fileId;
      RadPersistenceManager1.LoadState();
      RadPivotGrid1.Rebind();
     }
    }

    Thank you,
    Kalyani
  2. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 29 Apr 2014 Link to this post

    Hello Kalyani,

    Could you please try upgrading your application to the latest official SP1 release of the controls and verify if this works for you. This version contains several persistence improvements, including the OLAP binding scenarios.
    Give it a try and let me know if ti works for you.

    Regards,
    Maria Ilieva
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Kalyani
    Kalyani avatar
    20 posts
    Member since:
    Jul 2011

    Posted 29 Apr 2014 in reply to Maria Ilieva Link to this post

    Thank you so much.  The update got the example to work.   I have one more doubt.  In the example provided they store the details with a session key and it is stored in App_Data.  Is there an easy way to store this detail in sql database.  My aim is to store the details with a user name in a database.  So when the user comes again and logs in he can reload his previous settings.  I see that it is possible but I am unable to find a good example for this.

    Thank you,
    Kalyani
  5. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 02 May 2014 Link to this post

    Hello Kalyani,

    General information on how to enable session maintenance in SQL server could be find in the kb article below:
    http://support.microsoft.com/kb/317604


    Regards,
    Maria Ilieva
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  6. Stefania
    Stefania avatar
    107 posts
    Member since:
    May 2013

    Posted 20 May 2014 in reply to Maria Ilieva Link to this post

    Hi,
    I have the same issue but I need to save it on mySql db and I can't change anything on the IIS
  7. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 23 May 2014 Link to this post

    Hello Stefania,

    In this scenario no modification on your IIS should be made.


    Regards,
    Maria Ilieva
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017