Moving Controls between Panels

thread: 5 messages  |  last: a year ago  |  started: thursday, february 11, 2010, 10:20 am pst


#1  |  David M. Clark (Berwick, PA) United States of America Financial Contributor
Thursday, February 11, 2010, 10:20 AM PST

Hello

I have used the example concerning moving controls from one panel to the other.  I have been successful in populating the left panel with textboxes from my database.  I can move the controls from one panel to the other and back.  

Here is my dilema.   At save time I need to know which controls are contained in the right panel.  I actually need the Textbox[boxnum]->text.  

How do I get that info from the the Right panel

Here is my code.

           ...
             // Fill Textboxes with availalbe Pages, and put it into the left Panel
             $boxnum = null;
               $objavailablepageArray = Page::LoadAll();
               foreach($objavailablepageArray as $objavailablepage) {
                $boxnum++;
                // The parent must be the panel, because the panel is going to be responsible
               // for rendering it.
               $this->txtTextbox[$boxnum] = new QTextBox($this->pnlLeft);
               $this->txtTextbox[$boxnum]->Text = sprintf('%s', $objavailablepage);
               $this->txtTextbox[$boxnum]->Width = 250;
               $this->txtTextbox[$boxnum]->AddAction(new QClickEvent(), new QAjaxAction('MoveMe'));
               $this->txtTextbox[$boxnum]->ActionParameter = 'right';
          }
       ...

protected function MoveMe($strFormId, $strControlId, $strParameter) {
     
     if ($strParameter == 'left') {

               $pnlSource = $this->pnlRight;
               $pnlDestination = $this->pnlLeft;
               $newsource = 'right';
           } else {
               $pnlSource = $this->pnlLeft;
               $pnlDestination = $this->pnlRight;
               $newsource = 'left';
           }

           

           // Get the Source's Child Controls
 $objChildControl = $pnlSource->GetChildControl($strControlId);
 $objChildControl->ActionParameter = $newsource;
 $objChildControl->SetParentControl($pnlDestination);
}
...

#2  |  Ago Luberg (Tallinn) Estonia
Thursday, February 11, 2010, 12:28 PM PST

You have a method $pnl->GetChildControls(), which returns all child controls of $pnl. I hope this helps you.

#3  |  David M. Clark (Berwick, PA) United States of America Financial Contributor
Thursday, February 11, 2010, 1:49 PM PST

Thanks Ago

can I then use a foreach loop to get each one, and if so do I use
  foreach ($pnl as $mytuff)
$stuffIwant = $mystuff->Text
}
to get the text out?

Dave

#4  |  Ago Luberg (Tallinn) Estonia
Thursday, February 11, 2010, 1:53 PM PST

Well, basically yes. But remember, you might have other controls on the panel (button, label etc). So, I'd check for if ($ctl instanceof QTextBox) or something like that.

#5  |  David M. Clark (Berwick, PA) United States of America Financial Contributor
Friday, February 12, 2010, 9:02 AM PST

Thanks Ago

It is working just fine now.  I appreciate your help.

God Bless,

Dave



Copyright © 2005 - 2012, Quasidea Development, LLC
This open-source framework for PHP is released under the terms of The MIT License.