コード例 #1
0
 protected function Form_Create()
 {
     // Define the DataGrid
     $this->dtgPersons = new QHtmlTable($this);
     // Define Columns
     // This first example uses a callback to draw the column, which is the most versatile way of drawing a column.
     // In other examples, we will describe other column types that let you draw some standard column types.
     $col = $this->dtgPersons->CreateCallableColumn('First Name', [$this, 'dtgPerson_FirstName_Render']);
     $col->CellStyler->Width = 200;
     // style for the 'td' tag of the column
     $col = $this->dtgPersons->CreateCallableColumn('Last Name', [$this, 'dtgPerson_LastName_Render']);
     $col->CellStyler->FontBold = true;
     // style for the 'td' tag of the column
     // Specify the local Method which will actually bind the data source to the datagrid.
     // In order to not over-bloat the form state, the datagrid will use the data source only when rendering itself,
     // and then it will proceed to remove the data source from memory.  Because of this, you will need to define
     // a "data binding" method which will set the datagrid's data source.  You specify the name of the method
     // here.  The framework will be responsible for calling your data binding method whenever the datagrid wants
     // to render itself.
     $this->dtgPersons->SetDataBinder('dtgPersons_Bind');
     // Update the styles of all the rows, or for just specific rows
     // (e.g. you can specify a specific style for the header row or for alternating rows)
     // Note that styles are hierarchical and inherit from each other.  For example, the default RowStyle
     // sets the FontSize as 12px, and because that attribute is not overridden in AlternateRowStyle
     // or HeaderRowStyle, both those styles will use the 12px Font Size.
     // While there are a variety of ways to style tables QCubed, the easiest and most versatile is to use css
     // classes. These are defined at the top of the intro.tpl.php file in this example.
     $this->dtgPersons->HeaderRowCssClass = 'header-row';
     $this->dtgPersons->RowCssClass = 'row';
     $this->dtgPersons->AlternateRowCssClass = 'alt-row';
 }
コード例 #2
0
 protected function Form_Create()
 {
     $this->dtg = new QHtmlTable($this);
     $this->dtg->SetDataBinder('BindData');
     $col = $this->dtg->CreateCallableColumn('Link', [$this, 'dtg_LinkRender']);
     $col->HtmlEntities = false;
     $col = $this->dtg->CreateCallableColumn('Button', [$this, 'dtg_ButtonRender']);
     $col->HtmlEntities = false;
     $this->lblVars = new QLabel($this);
 }
コード例 #3
0
 protected function Form_Create()
 {
     // define the proxy that we will use later
     $this->pxyLink = new QControlProxy($this);
     $this->pxyLink->AddAction(new QMouseOverEvent(), new QAjaxAction('mouseOver'));
     // Define the DataGrid
     $this->tblProjects = new QHtmlTable($this);
     // This css class is used to style alternate rows and the header, all in css
     $this->tblProjects->CssClass = 'simple_table';
     // Define Columns
     // Create a link column that shows the name of the project, and when clicked, calls back to this page with an id
     // of the item clicked on
     $this->tblProjects->CreateLinkColumn('Project', '->Name', QApplication::$ScriptName, ['intId' => '->Id']);
     // Create a link column using a proxy
     $col = $this->tblProjects->CreateLinkColumn('Status', '->ProjectStatusType', $this->pxyLink, '->Id');
     $this->tblProjects->SetDataBinder('tblProjects_Bind');
     $this->pnlClick = new QPanel($this);
     if (($intId = QApplication::QueryString('intId')) && ($objProject = Project::Load($intId))) {
         $this->pnlClick->Text = 'You clicked on ' . $objProject->Name;
     }
 }
コード例 #4
0
 protected function Form_Create()
 {
     // Define the DataGrid
     $this->tblPersons = new QHtmlTable($this);
     $this->tblPersons->CssClass = 'simple_table';
     $this->tblPersons->RowCssClass = 'odd_row';
     $this->tblPersons->AlternateRowCssClass = 'even_row';
     $this->tblPersons->HeaderRowCssClass = 'header_row';
     // Define Columns
     // This demonstrates how to first create a column, and then add it to the table
     $objColumn = new QHtmlTableCallableColumn('Full Name', [$this, 'getFullName']);
     $this->tblPersons->AddColumn($objColumn);
     // The second column demonstrates using a property name for fetching the data
     // This also demonstrates how to create a column and add it to the table all at once, using the CreatePropertyColumn shortcut
     $this->tblPersons->CreatePropertyColumn('First Name', 'FirstName');
     // The second column demonstrates using a node column for fetching the data
     $this->tblPersons->CreateNodeColumn('Last Name', QQN::Person()->LastName);
     // Specify the local Method which will actually bind the data source to the datagrid.
     // In order to not over-bloat the form state, the datagrid will use the data source only when rendering itself,
     // and then it will proceed to remove the data source from memory.  Because of this, you will need to define
     // a "data binding" method which will set the datagrid's data source.  You specify the name of the method
     // here.  The framework will be responsible for calling your data binding method whenever the datagrid wants
     // to render itself.
     $this->tblPersons->SetDataBinder('tblPersons_Bind');
     $this->tblReport = new QHtmlTable($this);
     $this->tblReport->CssClass = 'simple_table';
     $this->tblReport->RowCssClass = 'odd_row';
     $this->tblReport->AlternateRowCssClass = 'even_row';
     $this->tblReport->HeaderRowCssClass = 'header_row';
     // "named" index columns
     $this->tblReport->CreateIndexedColumn("Year", 0);
     $this->tblReport->CreateIndexedColumn("Model", 1);
     // "unnamed" index columns
     $this->tblReport->CreateIndexedColumn();
     $this->tblReport->CreateIndexedColumn();
     // index columns for associative arrays
     $this->tblReport->CreateIndexedColumn("Count", "#count");
     $this->tblReport->SetDataBinder('tblReport_Bind');
     $this->tblComplex = new QHtmlTable($this);
     $this->tblComplex->CssClass = 'simple_table';
     $this->tblComplex->RowCssClass = 'odd_row';
     $this->tblComplex->AlternateRowCssClass = 'even_row';
     $this->tblComplex->HeaderRowCssClass = 'header_row';
     // "named" index columns
     $col = $this->tblComplex->AddColumn(new ComplexColumn("", "Name"));
     $col->RenderAsHeader = true;
     $this->tblComplex->AddColumn(new ComplexColumn("2000", 1));
     $this->tblComplex->AddColumn(new ComplexColumn("2001", 2));
     $this->tblComplex->AddColumn(new ComplexColumn("2002", 3));
     $this->tblComplex->HeaderRowCount = 2;
     $this->tblComplex->SetDataBinder('tblComplex_Bind');
 }
コード例 #5
0
 protected function Form_Create()
 {
     // Define the DataGrid
     $this->tblProjects = new QHtmlTable($this);
     // This css class is used to style alternate rows and the header, all in css
     $this->tblProjects->CssClass = 'simple_table';
     // Define Columns
     // Show the name of the project
     $this->tblProjects->CreateNodeColumn('Project', QQN::Project()->Name);
     // Date column formatting. Uses the Format string to format the date object that is in the column.
     $col = $this->tblProjects->CreateNodeColumn('Start Date', QQN::Project()->StartDate);
     $col->Format = 'MM/DD/YY';
     $col = $this->tblProjects->CreateNodeColumn('End Date', QQN::Project()->EndDate);
     $col->Format = 'DDD, MMM D, YYYY';
     // PersonAsTeamMemberArray is an array of names. Use a callback to format the array into a string.
     $col = $this->tblProjects->CreatePropertyColumn('Members', 'PersonAsTeamMemberArray');
     $col->PostCallback = 'ExampleForm::RenderTeamMemberArray';
     //
     $col = $this->tblProjects->CreateCallableColumn('Balance', [$this, 'dtgPerson_BalanceRender']);
     $col->CellParamsCallback = [$this, 'dtgPerson_BalanceAttributes'];
     $this->tblProjects->SetDataBinder('tblProjects_Bind');
 }
コード例 #6
0
 /**
  * Recreate the tabs in the dialog
  */
 protected function SetupTabs()
 {
     $strClassNames = $this->CreateClassNameArray();
     $this->tabs->RemoveChildControls(true);
     $this->categories = array();
     $this->dtgGeneralOptions = new QHtmlTable($this->tabs, 'definitionTab');
     $this->dtgGeneralOptions->ShowHeader = false;
     $this->dtgGeneralOptions->Name = "General";
     $this->dtgGeneralOptions->CreatePropertyColumn('Attribute', 'Name');
     $col = $this->dtgGeneralOptions->AddColumn(new QHtmlTableCallableColumn('Attribute', array($this, 'dtg_ValueRender'), $this->dtgGeneralOptions));
     $col->HtmlEntities = false;
     $this->dtgGeneralOptions->SetDataBinder('dtgGeneralOptions_Bind', $this);
     /**
      * The following default options are somewhat matched to the default list and edit templates. A more robust
      * implementation would get the options from the templates, or what the templates generate, so that the templates
      * decide what to put there. If someone wants to radically change the templates, but still have them use this dialog
      * to edit the options, then would be the time to change the code below.
      */
     if ($this->objCurrentControl->LinkedNode->_ParentNode) {
         // Specify general options for a database column
         $this->generalOptions = array(new QModelConnectorParam(QModelConnectorParam::GeneralCategory, 'ControlClass', 'Override of the PHP type for the control. If you change this, save the dialog and reopen to reload the tabs to show the control specific options.', QModelConnectorParam::SelectionList, $strClassNames), new QModelConnectorParam(QModelConnectorParam::GeneralCategory, 'FormGen', 'Whether or not to generate this object, just a label for the object, just the control, or both the control and label', QModelConnectorParam::SelectionList, array(QFormGen::Both => 'Both', QFormGen::None => 'None', QFormGen::ControlOnly => 'Control', QFormGen::LabelOnly => 'Label')), new QModelConnectorParam(QModelConnectorParam::GeneralCategory, 'Name', 'Control\'s Name', QType::String), new QModelConnectorParam(QModelConnectorParam::GeneralCategory, 'NoColumn', 'True to prevent a column in the lister from being generated.', QType::Boolean));
     } else {
         // Specify general options for a database table, meaning an object that is listing the content of a whole table.
         // These would be options at a higher level than the control itself, and would modify how the control is used in a form.
         $this->generalOptions = array(new QModelConnectorParam(QModelConnectorParam::GeneralCategory, 'ControlClass', 'Override of the PHP type for the control. If you change this, save the dialog and reopen to reload the tabs to show the control specific options.', QModelConnectorParam::SelectionList, $strClassNames), new QModelConnectorParam(QModelConnectorParam::GeneralCategory, 'Name', 'The Control\'s Name. Generally leave this blank, or use a plural name.', QType::String), new QModelConnectorParam(QModelConnectorParam::GeneralCategory, 'ItemName', 'The public name of an item in the list. Its used by the title of the edit form, for example. Defaults to the name of the table in the database.', QType::String), new QModelConnectorParam(QModelConnectorParam::GeneralCategory, 'CreateFilter', 'Whether to generate a separate control to filter the data. If the data list control does its own filtering, set this to false. Default is true.', QType::Boolean), new QModelConnectorParam(QModelConnectorParam::GeneralCategory, 'EditMode', 'How to edit an item. 1) Options are: to go to a separate form, 2) popup a dialog, or 3) popup a dialog only if not on a mobile device since mobile devices struggle with showing dialogs that are bigger than the screen.', QModelConnectorParam::SelectionList, array('form' => 'Edit with a QForm', 'dialog' => 'Edit with a QDialog', 'both' => 'Edit with a form on mobile devices, and a dialog on desktops.')));
     }
     // load values from settings file
     foreach ($this->generalOptions as $objParam) {
         $objControl = $objParam->GetControl($this->dtgGeneralOptions);
         // get a control that will edit this option
         $strName = $objControl->Name;
         if (isset($this->params[$strName])) {
             $objControl->Value = $this->params[$strName];
             if ($strName == 'ControlClass') {
                 $strControlClass = $this->params[$strName];
             }
         } else {
             $objControl->Value = null;
         }
     }
     if (!isset($strControlClass)) {
         $strControlClass = get_class($this->objCurrentControl);
     }
     $params = $strControlClass::GetModelConnectorParams();
     // gather categories
     foreach ($params as $param) {
         $this->categories[$param->Category][] = $param;
     }
     // Add any additional general items to the general tab
     if (isset($this->categories[QModelConnectorParam::GeneralCategory])) {
         // load values from settings file
         foreach ($this->categories[QModelConnectorParam::GeneralCategory] as $objParam) {
             $objControl = $objParam->GetControl($this->dtgGeneralOptions);
             // get a control that will edit this option
             $strName = $objControl->Name;
             if (isset($this->params[$strName])) {
                 $objControl->Value = $this->params[$strName];
             } else {
                 $objControl->Value = null;
             }
             $this->generalOptions[] = $objParam;
         }
         unset($this->categories[QModelConnectorParam::GeneralCategory]);
     }
     foreach ($this->categories as $tabName => $params) {
         $panel = new QPanel($this->tabs);
         $panel->SetCustomStyle('overflow-y', 'scroll');
         $panel->SetCustomStyle('max-height', '200');
         $panel->AutoRenderChildren = true;
         $panel->Name = $tabName;
         $dtg = new QHtmlTable($panel);
         $dtg->ShowHeader = false;
         $dtg->CreatePropertyColumn('Attribute', 'Name');
         $col = $dtg->AddColumn(new QHtmlTableCallableColumn('Attribute', array($this, 'dtg_ValueRender'), $dtg));
         $col->HtmlEntities = false;
         $dtg->SetDataBinder('dtgControlBind', $this);
         $dtg->Name = $tabName;
         // holder for category
         $this->datagrids[$tabName] = $dtg;
         // load values from settings file
         foreach ($params as $objParam) {
             $objControl = $objParam->GetControl($this->datagrids[$tabName]);
             if ($objControl) {
                 $strName = $objControl->Name;
                 if (isset($this->params['Overrides'][$strName])) {
                     $objControl->Value = $this->params['Overrides'][$strName];
                 } else {
                     $objControl->Value = null;
                 }
             }
         }
     }
 }