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

Save and load user selections

5 Answers 88 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
Kalyani
Top achievements
Rank 1
Kalyani asked on 24 Apr 2014, 07:50 PM
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

5 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 29 Apr 2014, 02:32 PM
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.

 
0
Kalyani
Top achievements
Rank 1
answered on 29 Apr 2014, 06:07 PM
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
0
Maria Ilieva
Telerik team
answered on 02 May 2014, 01:24 PM
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.

 
0
Stefania
Top achievements
Rank 2
answered on 20 May 2014, 03:22 PM
Hi,
I have the same issue but I need to save it on mySql db and I can't change anything on the IIS
0
Maria Ilieva
Telerik team
answered on 23 May 2014, 03:09 PM
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.

 
Tags
PivotGrid
Asked by
Kalyani
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Kalyani
Top achievements
Rank 1
Stefania
Top achievements
Rank 2
Share this question
or