Example #1
0
    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();
    }