Hi,
I have a database table with a list of questions. The questions need to be ordered by the user and the text can be edited. I'd like to allow the user to re-order the questions using drag and drop.
I am thinking that the dock control could be used to do this. I would need to generate the dock objects dynamically from the database with a text box in each. I want the user to be able to edit the text and rearrange the questions without any postbacks (or callbacks). Then when they click a Save button I want to get the text and new order and save it to my database.
Any suggestions on whether this can be done with this control would be greatly appreciated. Or whether another control would be more suitable. Any practical suggestions on code sequence or properties/APIs would be great.
I have a database table with a list of questions. The questions need to be ordered by the user and the text can be edited. I'd like to allow the user to re-order the questions using drag and drop.
I am thinking that the dock control could be used to do this. I would need to generate the dock objects dynamically from the database with a text box in each. I want the user to be able to edit the text and rearrange the questions without any postbacks (or callbacks). Then when they click a Save button I want to get the text and new order and save it to my database.
Any suggestions on whether this can be done with this control would be greatly appreciated. Or whether another control would be more suitable. Any practical suggestions on code sequence or properties/APIs would be great.
6 Answers, 1 is accepted
0
Hi skysailor,
RadDock should be enough for creating reorderable lists. I created a simple example for you which demonstrates how to achieve the requested functionality. You could extend it to support add / delete questions with or without AJAX. Let us know if you struggle with problems and we will help you.
Best wishes,
Valeri Hristov (Senior Developer, MCSD)
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
RadDock should be enough for creating reorderable lists. I created a simple example for you which demonstrates how to achieve the requested functionality. You could extend it to support add / delete questions with or without AJAX. Let us know if you struggle with problems and we will help you.
Best wishes,
Valeri Hristov (Senior Developer, MCSD)
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
skysailor
Top achievements
Rank 1
answered on 10 Jul 2007, 12:05 AM
You guys are awesome!
Thanks for the sample code. It is very helpful.
Thanks for the sample code. It is very helpful.
0
skysailor
Top achievements
Rank 1
answered on 10 Jul 2007, 06:32 AM
I have gotten this mostly working now. Loading and saving dock text and position works fine. Also adding new docks.
I'm having another problem though. If the user clicks on the X to close the dock then the Closed property of the dock is true when the user clicks the Save button. But I have added another button called Close All that calls set_Closed(true) on all docks. This does close the docks but when Save is clicked the closed property of the dock is not set. Is this a bug or am I doing something wrong?
I'm having another problem though. If the user clicks on the X to close the dock then the Closed property of the dock is true when the user clicks the Save button. But I have added another button called Close All that calls set_Closed(true) on all docks. This does close the docks but when Save is clicked the closed property of the dock is not set. Is this a bug or am I doing something wrong?
0
Hello skysailor,
This is a shortcoming of the control, which will be fixed in one of its next updates. To fix it you should call:
...
dock.set_Closed(true);
dock.updateClientState();
...
This should be enough. Let me know if you have additional troubles.
Regards,
Valeri Hristov (Senior Developer, MCSD)
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
This is a shortcoming of the control, which will be fixed in one of its next updates. To fix it you should call:
...
dock.set_Closed(true);
dock.updateClientState();
...
This should be enough. Let me know if you have additional troubles.
Regards,
Valeri Hristov (Senior Developer, MCSD)
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
skysailor
Top achievements
Rank 1
answered on 11 Jul 2007, 12:05 AM
I have gotten this all working now. Adding extra questions/docks that were not in the datbase was tricky. Here are some tips if others are trying to do the same thing.
You need to create all the RadDocks in the Pages Init event. This is noted in the docs and several examples. For a postback to work you need to create the exact same number of docks with the exact same names that were created when the page was first sent out. Then the data will be persisted back into the controls.
When adding docks dynamically this gets tricky. I have a button on the form to add a new question/dock. This creates a new dock and returns the updated page. When the page is posted back you need to recreate those docks. Adding the docks for the quetiona already in the database is easy. But you then need to recreate the dock(s) that have been added now (they may have clicked the Add button more than once before saving). So how many docks have been added?
To track that I added a HiddenField to the page with the count of added questions. Then on postback you can create that many docks with names that are numbered from 1 up to that number. But the docks need to be created in the Init event and the value of the HiddenField is not available yet. To get it you can use code like this :-
CogUtils.StrToIntDef(Request.Form[AddedQuestionsSave.UniqueID], ref AddedQuestions );
AddedQuestionsSave is the name of the HiddenField.
You need to create all the RadDocks in the Pages Init event. This is noted in the docs and several examples. For a postback to work you need to create the exact same number of docks with the exact same names that were created when the page was first sent out. Then the data will be persisted back into the controls.
When adding docks dynamically this gets tricky. I have a button on the form to add a new question/dock. This creates a new dock and returns the updated page. When the page is posted back you need to recreate those docks. Adding the docks for the quetiona already in the database is easy. But you then need to recreate the dock(s) that have been added now (they may have clicked the Add button more than once before saving). So how many docks have been added?
To track that I added a HiddenField to the page with the count of added questions. Then on postback you can create that many docks with names that are numbered from 1 up to that number. But the docks need to be created in the Init event and the value of the HiddenField is not available yet. To get it you can use code like this :-
CogUtils.StrToIntDef(Request.Form[AddedQuestionsSave.UniqueID], ref AddedQuestions );
AddedQuestionsSave is the name of the HiddenField.
0
Hi,
I am glad that you have everything all set. Furthermore, I would like to thank you for sharing your experience with our community and assisting us in providing better support and products of good quality. As a way to encourage such beneficial to our community actions, please find 1500 Telerik points added to your account.
Regards,
Petya
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
I am glad that you have everything all set. Furthermore, I would like to thank you for sharing your experience with our community and assisting us in providing better support and products of good quality. As a way to encourage such beneficial to our community actions, please find 1500 Telerik points added to your account.
Regards,
Petya
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center