Exemplo n.º 1
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');
 }
 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');
 }