protected function Form_PreRender() { // If an existing InventoryModel is being edited, render the Quantities by Location and Transaction history datagrids if ($this->ctlInventoryEdit->blnEditMode) { // Render the Quantities by Location datagrid $objExpansionMap[InventoryLocation::ExpandLocation] = true; $this->ctlInventoryEdit->dtgInventoryQuantities->TotalItemCount = InventoryLocation::CountByInventoryModelIdLocations($this->ctlInventoryEdit->objInventoryModel->InventoryModelId); // If there are no rows in the datagrid, do not show the header column if ($this->ctlInventoryEdit->dtgInventoryQuantities->TotalItemCount == 0) { $this->ctlInventoryEdit->dtgInventoryQuantities->ShowHeader = false; } else { $this->ctlInventoryEdit->dtgInventoryQuantities->ShowHeader = true; // $this->ctlInventoryEdit->dtgInventoryQuantities->DataSource = InventoryLocation::LoadArrayByInventoryModelId($this->ctlInventoryEdit->objInventoryModel->InventoryModelId, $this->ctlInventoryEdit->dtgInventoryQuantities->SortInfo, $this->ctlInventoryEdit->dtgInventoryQuantities->LimitInfo, $objExpansionMap); $this->ctlInventoryEdit->dtgInventoryQuantities->DataSource = InventoryLocation::LoadArrayByInventoryModelIdLocations($this->ctlInventoryEdit->objInventoryModel->InventoryModelId, $this->ctlInventoryEdit->dtgInventoryQuantities->SortInfo, $this->ctlInventoryEdit->dtgInventoryQuantities->LimitInfo, $objExpansionMap, true); } $objExpansionMap = null; // Specify the local databind method this datagrid will use $this->ctlInventoryEdit->dtgInventoryTransaction->SetDataBinder('dtgInventoryTransaction_Bind'); // Specify the local databind method this datagrid will use $this->ctlInventoryEdit->dtgShipmentReceipt->SetDataBinder('dtgShipmentReceipt_Bind'); } // If InventoryLocations are in the array, finish setting up the datagrid of InventorieLocations prepared for a transaction if ($this->ctlInventoryTransact->objInventoryLocationArray) { // Using the array instead of querying the database again. This means sorting will not work because the db is not being queried each time. $this->ctlInventoryTransact->dtgInventoryTransact->TotalItemCount = count($this->ctlInventoryTransact->objInventoryLocationArray); $this->ctlInventoryTransact->dtgInventoryTransact->DataSource = $this->ctlInventoryTransact->objInventoryLocationArray; $this->ctlInventoryTransact->dtgInventoryTransact->ShowHeader = true; } else { $this->ctlInventoryTransact->dtgInventoryTransact->TotalItemCount = 0; $this->ctlInventoryTransact->dtgInventoryTransact->ShowHeader = false; } }