QCalendar control disappears in QDatagrid
Fri, 09/03/2010 - 23:33
I have created a datagrid, which includes a QCalendar control. It seems to work fine, unless I need to rebind the data to the grid. For example,
$this->dtgMydatagrid = new QDatagrid;
...
$this->dtgWorkOrderOps->AddColumn(new QDataGridColumn('Operation', '<?= $_ITEM->OpCode ?>', 'Width=100'));
$this->dtgWorkOrderOps->AddColumn(new QDataGridColumn('Date Complete', '<?= $_FORM->chkDateOut_Render($_ITEM) ?>','HtmlEntities=false'));
...
$this->dtgWorkOrderOps->SetDataBinder('dtgWorkOrderOps_Bind');
...
public function dtgWorkOrderOps_Bind() {
$txtOrderByClause = QQ::Clause(QQ::OrderBy(QQN::Workorderops()->SequenceNo));
$objWorkorderops = Workorderops::LoadArrayByWorkorderhdrsId($this->intWorkOrderId->Text,$txtOrderByClause);
$this->WorkOrderOpsArray = array();
foreach ($objWorkorderops as $objWorkorderop) {
$this->WorkOrderOpsArray[] = $objWorkorderop;
}
$this->dtgWorkOrderOps->DataSource = $this->WorkOrderOpsArray;
}
...
public function chkDateOut_Render(Workorderops $objWorkorderop) {
$strControlId = 'DateOut' . $objWorkorderop->Id;
// See if the Checkbox exists already
$DateOut = $this->GetControl($strControlId);
if (!$DateOut) {
$DateOut = new QCalendar($this);
$DateOut->AddCssClass("dtgdates");
if ($objWorkorderop->DateComplete != NULL && $objWorkorderop->DateComplete != "") {
$DateOut->Text = $objWorkorderop->DateComplete->qFormat('MMM DD YYYY');
}
}
return $DateOut->Render(false);
}So far so good. The $DateOut displays as expected. However, if it is necessary to re-bind the data to the datagrid,
$this->dtgWorkOrderOps->DataSource = $this->WorkOrderOpsArray;the $DateOut control simply disappears. It's heading however, does not disappear. I just get an empty column with no control.
I've been searching through the code, but haven't found anything that jumps out at me. Help.
Thanks,
LaCeja

Oops, sorry, I'm using 2.0.
Actually, now that I've done more testing, when the form is submitted, there is no input from this control either.
I can't see anything wrong with the code. Can you run in a debugger and see if chkDateOut_Render() is actually being called when the data is re-binding? If yes what is the input it's getting and the text it's producing?
Okay, I got it. It's an error in creating the control. It looks like this:
$DateOut = new QCalendar($this);It should be:
$DateOut = new QCalendar($this,$strControlId);After looking much more closely at the Firebug output, I realized the Control Id was not being assigned as I "thought" I had defined it.
Vartan, thanks for looking at it.
LaCeja