This is a migrated thread and some comments may be shown as answers.
How do I disable or clear memory for the built-in functionality of RadPane remembering height/width?
5 Answers 24 Views
This is a migrated thread and some comments may be shown as answers.
Sean
Top achievements
Rank 2
Sean asked on 04 Nov 2011, 06:14 PM
Hi Telerik,

I am trying to implemented an 'Edit Mode' for my application. When exiting out of 'Edit Mode' the user has two options -- revert to old state, or save changes.

I noticed that when the option 'revert state' is chosen, even though I clear all my saved information, the RadPanes still retain their old dimensions. I know this is by design, and that's fine, but I would like to clear that memory from within a static method.

Basically, if the user refreshes the page -- everything is good. The ClientState information is lost, old data is loaded from our database, and the dimensions for the controls are set. But, when ClientState information is not lost, the old data is overwritten with the client state data.

If it's not possible to do within a static method, let me know the instructions anyway. I can probably re-implement the lost functionality in a way that would work for my project.

Thanks

Sean

5 Answers, 1 is accepted

Sort by
0
Dobromir
Telerik team
answered on 09 Nov 2011, 09:42 AM
Hi Sean,

Please take a look at the following live demo implementing similar scenario:
http://demos.telerik.com/aspnet-ajax/splitter/examples/saveloadstateonserver/defaultcs.aspx

Regards,
Dobromir
the Telerik team
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 their blog feed now
0
Sean
Top achievements
Rank 2
answered on 10 Nov 2011, 12:53 AM
Hi Dobromir,

This issue is not handled by the demo provided. In fact, it highlights the issue.


This is documented  and was not surprising to me, I am merely asking how to undo the provided functionality. 

The state of a RadSplitter automatically persists across postbacks, so you do not need to reconfigure it every time to maintain the same appearance. Even if you change the values of the properties listed below using the client-side API, they will persist across postbacks.

I have made a quick video which highlights this issue in my dashboard.

Initially, the video will load and there are some panes/splitters on the dashboard. These have been saved to a database, session, and are loaded / retained across postbacks.

Then, I add some extra controls to the page. These are newly added and have not been saved to the database. When I click 'Cancel Changes' I clear everything in Session (as to forget), and then reload my information from the database. This causes the controls to revert back to their previously known information.

This works for everything except the dimensions of the panes. I have not written the resize to the database, and I have cleared Session. As such, I have no memory of this move, but it is retaining its own memory somewhere. I would like to tell it "Hey, act like you've never resized before" so that when I re-apply my information from the database it is not overwritten by unsaved actions.

http://screencast.com/t/07i4zhlJes

I hope this all makes sense. :) 

Sean

0
Dobromir
Telerik team
answered on 14 Nov 2011, 02:48 PM
Hi Sean,

Thank you for the detailed explanation and the provided video.

This built-in behavior of the splitter (to persists its state over postbacks) cannot be disabled and if you want to revert the original state of the panes' width / height you need to set them explicitly when recreating the control but in a later stage of the Page's lifecycle (later than Page_Init). This requirement is due to the fact that splitter is loading its client state in the ProccesPostData stage of the InitComplete.

Kind regards,
Dobromir
the Telerik team
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 their blog feed now
0
Sean
Top achievements
Rank 2
answered on 15 Nov 2011, 11:01 PM
Hi Dobromir,

That sucks! I was hoping that since RadPane has the PersistScrollPosition property that it wouldn't be a far cry to have another Persist property.

I'm going to log this into PITS... For anyone who needs this in the future -- the best solution I could come up with was just writing to Session. Anything else would couple the knowledge of "getting data from database" with the objects.. trying to keep that all decoupled. 

[WebMethod]
public static bool RevertToLastSave()
{
    bool successful = false;
 
    try
    {
        StateManager.RevertToLastSave();
        SessionRepository.Instance.SetSession("cleared", true);
        successful = true;
    }
    catch (Exception exception)
    {
        _logger.ErrorFormat("Unable to revert changes. Reason: {0}", exception.Message);
    }
 
    return successful;
}
 //Page_Load:
object justCleared = SessionRepository.Instance.GetSession("cleared");
 
if(!Equals(justCleared, null) && (bool)justCleared)
{
    List<RadPaneSetting> settings = StateManager.GetStates<SerializableDictionary<string, RadPaneSetting>>().Select(state => state.Value).ToList();
 
    foreach (CormantRadPane pane in LayoutManager.Instance.RegisteredPanes)
    {
        RadPaneSetting paneSetting = settings.FirstOrDefault(setting => int.Equals(setting.ID, pane.ID));
        if (Equals(paneSetting, null))
        {
            _logger.DebugFormat("Failed to find settings for {0} when trying to set dimensions.", pane.ID);
            continue;
        }
        if (int.Equals(paneSetting.Height, 0) || int.Equals(paneSetting.Width, 0)) continue;
        pane.Height = paneSetting.Height;
        pane.Width = paneSetting.Width;
    }
    SessionRepository.Instance.SetSession("cleared", false);
}
0
Dobromir
Telerik team
answered on 21 Nov 2011, 12:01 PM
Hi Sean,

I have brought your request to the attention of the developers of RadSplitter and we will consider implementing property to control the client state.

Regarding your solution, I believe its the best one. In all cases, you need to have two different states of the panes: one to store the original state and one to store current state; otherwise, how would you preserve the changes over postbacks that are not related to Save Changes / Cancel Changes actions?

Greetings,
Dobromir
the Telerik team
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 their blog feed now
Asked by
Sean
Top achievements
Rank 2
Answers by
Dobromir
Telerik team
Sean
Top achievements
Rank 2
Share this question
or