Hello All,
I am trying to create a "form layout designer" using RadTabStrip, RadPageView, RadDocks, as follows:
Ignore the code about re-creating the tab collection - I'll use that later when I serialize/de-serialize to the database. Using reference code from Telerik, I have attached handlers for the SaveDockLayout and LoadDockLayout, like so:
And finally, inside the handlers:
I also have all the related code to "create dock from state", "save state trigger", and so on. It seems that these are getting called correctly, but still I get the symptoms described above!
Any ideas on what I'm missing here?
Allen
I am trying to create a "form layout designer" using RadTabStrip, RadPageView, RadDocks, as follows:
- A user can dynamically add tabs to the tab strip
- At the same time that a tab strip is added, I automatically add a page view "behind the scenes" so that there is a 1:1 correspondence with the tabs
- Inside each page view I automatically add a RadDockLayout
- A user can then dynamically add RadDockZones inside each layout (I am managing the placement and width via a combination of CSS and properties)
- Finally, users are free to select from a number of RadDocks, which then contain the form content, which they can then move freely between dock zones
I have gotten items 1-4 working fine - the positioning of dock zones remains stable and predictable between post-backs. However, I am having trouble getting #5 to work reliably. Among the symptoms I see:
- Only 1 dock appears after repeatedly adding docks to dock zones
- After postback, even the 1 dock disappears
Some details: as emphasized by the vast majority of documentation, it is best to create/re-create everything in Page_Init. Thus, I have:
protected void Page_Init(object sender, EventArgs e) |
{ |
// Re-create tabs (from persistence store) on the first page visit only |
if (!Page.IsPostBack) |
{ |
for (int i = 0; i < CurrentTabCollection.Count; i++) { } |
} |
// Re-create page views |
foreach (KeyValuePair<string, int> pageViewTuple in CurrentPageViewIdCollection) { CreateNewPageView(pageViewTuple.Key, pageViewTuple.Value); } |
// Re-create dock layouts |
foreach (KeyValuePair<string, int> dockLayoutTuple in CurrentDockLayoutIdCollection) { CreateNewDockLayout(dockLayoutTuple.Key, dockLayoutTuple.Value); } |
// Re-create dock zones |
foreach (KeyValuePair<string, string> dockZoneTuple in CurrentDockZoneIdCollection) { CreateNewRadDockZone(dockZoneTuple.Key, dockZoneTuple.Value); } |
// Re-create docks |
for (int i = 0; i < CurrentDockStateCollection.Count; i++) |
{ |
RadDock dock = CreateRadDockFromState(CurrentDockStateCollection[i]); |
CreateSaveStateTrigger(dock); |
} |
} |
Ignore the code about re-creating the tab collection - I'll use that later when I serialize/de-serialize to the database. Using reference code from Telerik, I have attached handlers for the SaveDockLayout and LoadDockLayout, like so:
private void CreateNewDockLayout(string dockLayoutId, int parentTabIndex) |
{ |
var newDockLayout = new RadDockLayout { ID = dockLayoutId }; |
newDockLayout.SaveDockLayout += FormSectionsRadDockLayout_SaveDockLayout; // Assign dock layout save handler |
newDockLayout.LoadDockLayout += FormSectionsRadDockLayout_LoadDockLayout; // Assign dock layout load handler |
FormSectionsRadMultiPage.PageViews[parentTabIndex].Controls.Add(newDockLayout); |
} |
And finally, inside the handlers:
protected void FormSectionsRadDockLayout_SaveDockLayout(object sender, DockLayoutEventArgs e) |
{ |
// Save the dock state in session |
CurrentDockStateCollection = ((RadDockLayout)sender).GetRegisteredDocksState(); |
} |
protected void FormSectionsRadDockLayout_LoadDockLayout(object sender, DockLayoutEventArgs e) |
{ |
// Populate event args with state information; the RadDockLayout control will automatically move the docks according to this information |
foreach (DockState state in CurrentDockStateCollection) |
{ |
e.Positions[state.UniqueName] = state.DockZoneID; |
e.Indices[state.UniqueName] = state.Index; |
} |
} |
I also have all the related code to "create dock from state", "save state trigger", and so on. It seems that these are getting called correctly, but still I get the symptoms described above!
Any ideas on what I'm missing here?
Allen