public function generate() { if (!count($this->columnWidth)) { return ''; } // default code for row selection if ($this->select != '') { $select = MActionControl::getHref($this->select); $this->addCode("{$this->tableId}.customSelect = function() { " . "var cells = this.get(this.rowSelected);" . "var url = '{$select}'; " . "for (c = 0; c < cells.length; ++c) {" . " url = url.replace('%' + c + '%', cells[c]);" . "}" . "manager.doLinkButton(url,'','','{$this->tableId}'); " . "};"); } $data = json_encode($this->value); $cols = json_encode($this->title); foreach ($this->columnStyle as $i => $style) { $cssCode .= ".field-" . $this->title[$i] . ' ' . ($style ?: '{}') . ' '; } $cssCode .= '.dgrid-row-even {background-color: #EEE}'; Manager::getPage()->addStyleSheetCode($cssCode); $template = new MTemplate(__DIR__); $template->context('manager', Manager::getInstance()); $template->context('data', $data); $template->context('cols', $cols); $template->context('id', $this->id); $js = $template->fetch('mtexttable.js'); $this->page->onLoad($js); $div = new MContentpane($this->id); $div->setWidth($this->width); $div->setHeight($this->scrollHeight); return $div->generate(); }
public function generate() { $this->page->addDojoRequire('manager.DGrid'); $this->generateColumns(); $columns = json_encode($this->dcolumns); $this->page->onLoad("{$this->id} = new Manager.DGrid('{$this->id}',{$this->firstIndex},'{$this->type}');"); $this->page->onLoad("{$this->id}.idSelect = '{$this->idSelect}';"); $this->page->onLoad("{$this->id}.firstIndex = {$this->firstIndex};"); $value = array(); foreach ($this->value as $i => $row) { foreach ($row as $j => $col) { $value[$i][$j] = $col->generate(); } } $data = json_encode($value); $this->page->onLoad("{$this->id}.columns = {$columns};"); $this->page->onLoad("{$this->id}.actionData = '{$this->actionData}';"); $this->page->onLoad("{$this->id}.startup();"); $div = new MContentpane($this->id); $div->setClass('mGrid'); $div->setWidth($this->width); $this->scrollHeight = '20em'; if ($this->scrollHeight) { $div->setHeight($this->scrollHeight); } else { // estilos para height:auto $this->cssCode .= <<<HERE #{$this->id} { height: auto; \t\t} \t\t#{$this->id} .dgrid-scroller { position: relative; overflow-y: hidden; \t\t} \t\t.has-ie-6 #{$this->id} .dgrid-scroller { /* IE6 doesn't react properly to hidden on this page for some reason */ overflow-y: visible; \t\t} \t\t#{$this->id} .dgrid-header-scroll { display: none; \t\t} \t\t#{$this->id} .dgrid-header { right: 0; \t\t} HERE; } Manager::getPage()->addStyleSheetCode($this->cssCode); return $div->generate(); }