This is a migrated thread and some comments may be shown as answers.
Saving the state of the docks using AJAX
1 Answer 34 Views
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 1
Martin asked on 17 Jun 2009, 03:03 PM
I really don't want to do postback, because we have a lot of controls created programmatically.
I see that through javascript I basically get the information I need:

 


function
OnClientDockPositionChanged(sender, args) {

 

alert(sender.get_dockZoneID());

alert(sender.get_uniqueID());

alert(sender.get_collapsed());

alert(sender.get_closed());

}

Do you have an example when the state of the docks is saved and loaded using web service call through AJAX's 

 

PageMethods?

1 Answer, 1 is accepted

Sort by
0
Martin
Top achievements
Rank 1
answered on 17 Jun 2009, 08:27 PM
I got it accomplished, the saving works without a single postback.
This is a much better solution then using the server side, which can become hell if you have lots of dynamically generated controls.

So to recap you have to do the following:
- declare all your zones
- use get_docks for each zone and concat it to a master array
- loop through that master array creating a custom JSON string with only three entries if you are only interested in positioning
use a PageMethods web service call to save your selection in whatever storage media you desire Session, Cookies, DB
- then add on Page_Init  LoadDockLayout
- the LoadDockLayout event handler uses the standard load routine found in the doc

 

if (!Page.IsPostBack)

 

{

 

String dockState = //your data media here
if (dockState != null)

 

{

 

string serializedList = dockState;

 

 

if (serializedList != null)

 

{

 

string[] states = serializedList.Split('|');

 

 

for (int i = 0; i < states.Length; i++)

 

{

 

DockState state = DockState.Deserialize(states[i]);

 

e.Positions[state.UniqueName] = state.DockZoneID;

e.Indices[state.UniqueName] = state.Index;

}

}

}

works like a charm

Tags
Dock
Asked by
Martin
Top achievements
Rank 1
Answers by
Martin
Top achievements
Rank 1
Share this question
or