8. Advanced Controls Manipulation
Dynamically Changing a Control's Parent
<< Introduction to QBlockControls   |   Back to Main   |   Creating Your Own Control >>

View Source
will open in a new window
Moving Controls Between Panels
With the concept of a QLabel or QPanel being able to have an arbitrary number of child controls, we use this example to show how you can dynamically change a control's parent, to essentially "move" a control from one panel to the next.

The example below has two QPanel controls, as well as ten QTextBox controls who's parents are one of the panels. The buttons have QAjaxActions which will move the textboxes back and forth between the panels, or remove the textbox altogether.

Again, note that we are not hard coding a QTextBox->Render anywhere in our code. We are simply using the concept of ParentControls and using the two QBlockControl controls' AutoRenderChildren functionality to dynamically render the textboxes in the appropriate places.

Finally, notice that while we are doing this using AJAX-based actions, you can just as easily use Server-based actions as well.