I use dockzone to load docks in. each dock is user control. I have a dropdownlist which user select and then it will load the existing dockstates
the issue now is that the dock order mess up after I switch dropdownlist selection. example: for dropdownlist, it has value "a" and value "b". when I select value "A", it will load dockstate1 and then when I select value "b", it will load dockstate2 from database. now I select value "A" and the dockstate1 is loaded and docks are ordered correctly. then I change some dock's postion by drag and drop. every thing works fine and dock index saved to database with correct number. then I select value "b" so dockstate2 is loaded. Then I reselect value "a", the dockstate1 is reloaded from database with correct index but the dock orders are changed. they order with the Alphbetic instead of the previous order. I found the dock/state index value changed after RadDockLayout1.GetRegisteredDocksState() is called. why the dock index change ? Please see rough codes
10 Answers, 1 is accepted
Since the order of RadDocks is not persisted correctly, most probably the layout of the dock controls is not saved or there are problems with loading it. I am willing to help you, but I will need a fully runnable project in order to inspect how the docks are created and added on the page, how is their layout saved and then loaded. I can suggest checking the online demo My Portal as it is a good example of loading RadDocks dynamically and saving their state.
Please note that currently I am mostly guessing as to what your setup is. If the encountered issue persist, please prepare and send a sample, runnable project that isolates the problem at hand so that we can examine it locally and suggest an appropriate solution.
the Telerik team
Thanks for your information. the link for submit solution doesn't work .Can I exmplain my code and logical instead of building runable project? I use SQL2000 and can't create MDF
Basically I can't load dock from widgetstate on page Init event. the reason is that I need to get data from other events which is fired after page_init then I can load dock after the event fired.
so the process is:
1. on page init, no load for dock
2.on Radcombox select index to load widgetstate from the database based on what I selected from Radcombox
3.after I load widgetstate from the database then I create dock from this widgetstate
4. then RadDockLayout1_LoadDockLayout event fire
5. then RadDockLayout1_SaveDockLayout event fired. actually I shouldn't need call this event since the widgetState is loaded from database and nothing changed
I will copy codes based on this steps. can you please look at to help out my issue?
1.Radcombox select index event:
I think I kindly figured out why my dock order issue but I am not sure how to fix it
Basically on my situation, when I change the selection from the RadCombox, I couldn't load dock from the page_init since I need to reload the dockstate from the database on the selectindex change event which is fired after page_init and after the
RadDockLayout1_LoadDockLayout. so on RadDockLayout1_SaveDockLayout, the state is not correct when I retrieved from RadDockLayout1.GetRegisteredDocksState(). I am still confused why the index changed automatically but I am assuming I need to fire
RadDockLayout1_LoadDockLayoutafter I get the latest state from the database. so the question is that how I can fire
RadDockLayout1_LoadDockLayout manually ? Could you please help out with this issue and I really need to fix it asap
I will explain the process of persisting the layout of the RadDocks so that you can get better understanding of it and check if there is something incorrect in your implementation:
1. On Page_Init the RadDocks that were present on the page before postback are recreated based on the state saved in the data base.
2. On RadDockLayout_LoadDockLayout the position and the index of every RadDock is recovered from the state, saved in the data base.
3. On RadDockLayout_SaveDockLayout the new state of the RadDocks is taken from the method of the RadDockLayout GetRegisteredDocksState() and it is stored in the data base to be used on a new page load.
Since RadDockLayout_LoadDockLayout is raised always in the correct moment of the page lifecycle, you won't need to fire it manually. Also, I checked the provided code samples and I wasn't able to detect what may be causing the issue. Note that I will need to examine your full code in order to detect the exact cause as the presented parts doesn't create a complete picture of your implementation.
Please find attached a sample project that demonstrates the default setup, utilized in such cases. You can compare it with your actual project and check if there are differences in the implementation. I would suggest trying to modify it so that the problem is reproducible or preparing a sample, runnable project that isolates the problem at hand and sending it to firstname.lastname@example.org so that we can examine it locally and provide a more to the point answer.
the Telerik team
Thanks for your explaination. so my code does have issue. I have to load the widgetstate from the database on the selectindexchange event instead of pate_init. It means I only can get all the state after LoadDockLayout fired since the Radcombox selectedindexchange event fire after page_init and after LoadDockLayout . is any way that I call LoadDockLayout after the selectedindexchange event ?
I tried to copy all the codes from RadCombox selectindexChange event to Page_init. then the Dock order issue is fixed. but as I mentioned, I have to leave code inside RadCombox selectindexChange in order to get some data informatio. so my issue or solution is : is it possible to do the same function which Load_layout do (the position and the index of every RadDock is recovered from the state, saved in the data base.) ouotside page_init?
Thank you for the sample and the description of your implementation. After examining your code I have several suggestions for improving your project:
1. For setting the index and position of the RadDocks outside the event LoadDockLayout you can use the method SetRegisteredDockParents of RadDockLayout, which is demonstrated in the online demo Dock / Load/Save Layout.
2. I would recommend separating the logic for recreating the RadDocks in the according events - you can load the controls on Init and populate them with additional information on SelectedIndexChanged of the RadComboBox control.
3. I noticed that in the handler of the server-side event LoadDockLayout you are using the state, returned from the GetRegisteredDocksState method of the RadDockLayout.
This is incorrect, as for setting the correct position and index of the recreated RadDocks you should utilize the data, stored in the data base.
I hope the information listed above will help you in resolving the issue.
the Telerik team
Thanks for your information.Can you please confirm why the viewstate varibale is missing after I drag and drop the dock? I have to use session instead of viewstate now to keep variable value.but I can't understand why the viewstate will not work when drag and drop
dock ( dock position change). Also can you please tell me how I can tell dock is drag and drop event? example: I can tell if the event is from RadCombox by checking the eventTarget . is any way for me to tell the page refresh because of dock drag and drop. I only need to save dockstate when dock change position or dock close ( by dock command) so want to know how to check
Indeed, the variable SystemUserWidgetID which is stored in ViewState is missing after a postback. This happens because you are setting its value on the RadDockLayout's event SaveDockLayout, which is raised after the ViewState of the page and its controls is saved, as you can check in this article. An alternative approach, that you may consider if you want to keep using the SaveDockLayout event for this purpose, is to store the current index of the RadComboBox in a hidden field instead of the ViewState.
If you want to save the state of the RadDock controls only when a dock is dragged or a command is clicked, you can use its server-side events Command and DockPositionChanged in order to set a flag, indicating that the state of the RadDocks should be saved. In the handler of the event SaveDockLayout you will save the state only if this flag is set.
the Telerik team