コード例 #1
0
 public function generateInner()
 {
     $num_rows = $this->getRowCount();
     $num_cols = $this->getColumnCount();
     if ($num_rows && $num_cols) {
         $table = new MSimpleTable($obj->name);
         $table->setAttribute('width', '100%');
         $table->setCell(0, 0, $this->top, "align=\"center\" colspan={$num_cols}");
         $table->setCell(1, 0, $this->left, "align=\"center\" valign=\"top\"");
         $table->setCell(1, 1, $this->center, "align=\"center\" valign=\"top\" width=\"100%\"");
         $table->setCell(1, 2, $this->right, "align=\"center\" valign=\"top\"");
         $table->setCell(2, 0, $this->bottom, "align=\"center\" colspan={$num_cols}");
         $this->inner = $table;
     }
 }
コード例 #2
0
ファイル: mgrid.php プロジェクト: joshuacoddingyou/php
 public function generateTable()
 {
     $width = $this->scrollable ? $this->scrollWidth - 25 . 'px' : $this->width;
     $table = new MSimpleTable($this->id, array("width" => $width, "class" => "mGrid"));
     $p = 0;
     $last = count($this->columns) - 1;
     foreach ($this->columns as $k => $column) {
         if ($column instanceof MGridAction) {
             if ($column->type == 'select') {
                 $rowCount = count($this->data);
                 $this->page->onLoad("{$this->name}.idSelect = '{$this->idSelect}';");
                 $this->page->onLoad("{$this->name}.firstIndex = {$this->firstIndex};");
                 $check = new MCheckBox($this->name . "chkAll", 'chkAction', '');
                 $check->addEvent('click', $this->name . ".checkAll({$rowCount});");
                 $table->setHead($p, $check);
                 $table->setHeadClass($p++, 'select');
             } elseif ($column->type == 'icon') {
                 $table->setHead($p, new MDiv('', '', 'managerIcon'));
                 $table->setHeadClass($p++, 'action');
             } elseif ($column->type == 'text') {
                 $table->setHead($p++, new MDiv('', '', ''));
             }
         } elseif ($column instanceof MGridColumn) {
             if (!$column->visible) {
                 continue;
             }
             if ($column->order) {
                 $this->orderBy = $k;
                 $link = new MLinkButton('', $column->title, $this->getURL($this->filtered, true));
                 $link->setClass('order');
                 $colTitle = $link;
                 $table->setHeadClass($p, 'order');
             } else {
                 $colTitle = $column->title;
             }
             if ($column->width) {
                 $attr = $k != $last ? " width=\"{$column->width}\"" : '';
                 //" width=\"100%\"";
             }
             $table->setHead($p++, $colTitle);
         }
     }
     if ($this->data) {
         // generate data rows
         $i = 0;
         $firstRow = true;
         foreach ($this->data as $row) {
             // foreach row
             $this->currentRow = $i;
             $this->currentIndex = $this->firstIndex + $i;
             $rowId = $i % 2;
             $rowClass = $this->alternateColors ? "row{$rowId}" : "row";
             if ($this->dnd) {
                 $rowClass .= '  dojoDndItem';
             }
             if ($this->lookupName != '') {
                 $rowClass .= '  rowLookup';
             }
             $c = $this->hasDetail ? $i + $this->currentRow : $i;
             $i++;
             //$table->setRowAttribute(0, "id", 'tbody' . $this->id . 'first');
             $table->setRowAttribute($c, 'id', $this->name . "-row-" . $this->currentIndex);
             $table->setRowClass($c, $rowClass);
             $this->generateColumnsControls($this->currentRow, $row);
             $this->callRowMethod();
             // generate Columns
             $row = $this->currentRow;
             $p = 0;
             //$last = count($this->columns) - 1;
             foreach ($this->columns as $k => $column) {
                 $control = $column->control[$row];
                 if ($column instanceof MGridAction) {
                     if ($column->type == 'select') {
                         $table->setCellClass($row, $p, 'select');
                     } elseif ($column->type == 'icon') {
                         $table->setCellClass($row, $p, 'actionIcon');
                     }
                     $table->setCell($row, $p++, $control);
                     //} elseif ($column instanceof MGridActionText) {
                     //$table->setCellClass($row, $p, 'actionText');
                     //    $table->setCell($row, $p++, $control);
                 } elseif ($column instanceof MGridColumn) {
                     if (!$column->visible) {
                         continue;
                     }
                     if ($column->width && $firstRow) {
                         //$attr = ($k != $last) ? " width=\"$column->width\"" : " width=\"100%\"";
                         $attr = " width=\"{$column->width}\"";
                         $table->setCellAttribute($row, $p, $attr);
                     }
                     if ($column->nowrap) {
                         $table->setCellAttribute($row, $p, "nowrap");
                     }
                     if (trim($column->align)) {
                         $table->setCellAttribute($row, $p, "style='text-align:{$column->align}'");
                     }
                     $class = $column->getClass();
                     if ($class) {
                         $table->setCellClass($row, $p, $class);
                     }
                     $table->setCell($row, $p++, $control);
                 }
             }
             $firstRow = false;
             // end generate columns
         }
         // end foreach row
     }
     // end if
     return $table;
 }