2013-01-01 80 views

回答

1

您可以利用QPanel控件實時添加控件。只需將其AutoRenderChildren屬性設置爲true,並將動態控件父級設置爲QPanel即可。

// Instantiate our QPanel - this will render a div to contain our dynamic controls 
// Note that the parent is $this. You will need to call render in your template 
$this->pnl = new QPanel($this); 
// Setting AutoRenderChildren so that the Panel will handle Rendering our dynamic 
// controls. 
$this->pnl->AutoRenderChildren = true; 
// Creating a button with an Ajax action to create our dynamic controls 
$this->btn = new QButton($this); 
$this->btn->Text = "Add Control"; 
$this->btn->AddAction(new QClickEvent(), new QAjaxAction('btn_Click')); 

protected function btn_Click($strFormId, $strControlId, $strParameter) { 
    // create the control and set its parent to the QPanel 
    $ctl = new QTextBox($this->pnl);   
} 

您可以在QCubed示例網站上獲得有關使用QPanel的更多信息。

QCubed QPanel Example