MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
mactivegrid.class
Ir para a documentação deste ficheiro.
1<?php
2class MActiveGrid extends MGrid
3{
10
11 function __construct($data, $columns, $href, $pagelength = 15, $index = 0)
12 {
13 parent::__construct($data, $columns, $href, $pagelength, $index);
15 $style = $this->manager->GetAbsoluteURL('scripts/activewidgets/runtime/styles/classic/grid.css');
16 $page->SetCompliant(false);
17 $page->AddStyleURL($style);
18 $page->AddScript('activewidgets/runtime/lib/grid.js');
19 $this->pagelength = 0;
20 $this->agHeight = 200;
21 $this->agWidth = 0;
22 $this->fullWidth = 0;
23 $this->fullHeight = 0;
24 $this->agScript = '';
25 $this->agStyle = "\n";
26 $this->name = "_grid_" . uniqid('ag');
27 $this->pn = $this->pagelength ? new MGridNavigator($this->pagelength, $this->rowCount,
28 $this->GetURL($this->filtered, $this->ordered), $this) : NULL;
29 }
30
32 {
33 $this->agStyle .= "$style\n";
34 }
35
36 function AddAgScript($script)
37 {
38 $this->agScript .= "$script\n";
39 }
40
41 function SetFullWidth($value)
42 {
43 $this->fullWidth = $value;
44 }
45
46 function SetFullHeight($value)
47 {
48 $this->fullHeight = $value;
49 }
50
51 function GenerateData()
52 {
53 if (!$this->data)
54 return;
55
56 if ($this->pagelength)
57 {
58 $this->pn->SetGridParameters($this->pagelength, $this->rowCount, $this->GetURL($filtered, $this->ordered), $this);
59 $this->data = $this->GetPage();
60 }
61 else
62 $this->pn = null;
63 }
64
65 function GenerateColumnsHeading($tbl=NULL)
66 {
67 $this->fullWidth -= 20;
68 $colsWidth = $this->fullWidth;// - (count($this->columns) * 4);
69 $p = 0;
70 $sc = "\nvar _{$this->name}_columns = [\n";
71 if ($cntActions = count($this->actions))
72 {
73 $n = $cntActions * 20;
74 $this->AddAgStyle(".active-column-{$p} {width: {$n}px;}");
75 $sc .= "\"Action\"";
76 $this->agWidth += $n;
77 $colsWidth -= $n;
78 $p++;
79 }
80
81
82 if ($this->select != NULL)
83 {
84 }
85
86 // generate column headings
87 foreach ($this->columns as $k => $col)
88 {
89 if ((!$col->visible) || (!$col->title))
90 continue;
91 if (strpos($col->width,'%') !== false)
92 {
93 $w = str_replace('%','',$col->width);
94 $col->width = (int)($w * $colsWidth / 100);
95 }
96 $this->AddAgStyle(".active-column-{$p} {width: {$col->width}px;}");
97 $sc .= ($p ? ',' : '') . "\"{$col->title}\"";
98 $p++;
99 $this->agWidth += $col->width;
100 }
101 $sc .= "\n];\n";
102 $this->AddAgScript($sc);
103 }
104
105 function GenerateActions(&$ac)
106 {
107 $i = $this->currentRow + 1;
108 if ($n = count($this->actions))
109 {
110 $ac .= "[\"";
111 foreach ($this->actions as $k => $action)
112 {
113 $control = $action->Generate();
114// $control->AddStyle('float','left');
115 $html = addSlashes($control->Generate());
116 $ac .= "{$html}&nbsp;";
117 }
118 $ac .= "\"],\n";
119 }
120
121 if ($this->select != NULL)
122 {
123 }
124 }
125
126 function GenerateColumns($tbl = NULL, $row, $i)
127 {
128 $i = $this->currentRow + 1;
129 $p = count($this->actions);
130
131 if ($this->select != NULL)
132 $p++;
133
134 $sc = "["; $n = 0;
135 foreach ($this->columns as $k => $col)
136 {
137 if ((!$col->title) || (!$col->visible))
138 continue;
139
140 $control = $col->control[$this->currentRow];
141 $attr = "";
142
143 if ($col->nowrap)
144 {
145 $attr .= " nowrap ";
146 }
147
148 if ($col->width)
149 {
150 $attr .= " width=\"$col->width\"";
151 }
152
153 if ($col->align)
154 {
155 $attr .= " align=\"$col->align\"";
156 }
157 $value = $control->GetValue();
158 $sc .= ($n++ ? ',' : '') . "\"{$value}\"";
159 }
160 $sc .= "],";
161 $this->AddAgScript($sc);
162 }
163
165 {
166 $this->GenerateColumnsHeading();
167
168 if ($this->data)
169 {
170 $ac = '';
171 $this->AddAgScript("var _{$this->name}_data = [");
172 $this->currentRow = 0;
173 foreach ($this->data as $row)
174 {
175 $this->GenerateColumnsControls();
176 $this->CallRowMethod();
177 $this->GenerateActions($ac);
178 $this->GenerateColumns($tblData);
179 $this->currentRow++;
180 } // foreach row
181 $this->AddAgScript("];");
182 if ($ac != '')
183 {
184 $this->AddAgScript("var _{$this->name}_actions = [");
185 $this->AddAgScript($ac);
186 $this->AddAgScript("];");
187 }
188 } // if
189 }
190
192 {
194 $nameData = "_{$this->name}_data";
195 $nameColumns = "_{$this->name}_columns";
196 $nameActions = "_{$this->name}_actions";
197 $countColumn = count($this->columns) + (count($this->actions) ? 1 : 0);
198//var_dump($this->agWidth);
199 $this->agWidth = (($this->fullWidth > 0) ? $this->fullWidth : $this->agWidth) + ($countColumn * 4);
200 $this->agHeight = (($this->fullHeight != 0) ? $this->fullHeight : $this->agHeight) - 15;
201 $pageSize = $sz = count($this->data);
202 $this->AddAgStyle(".active-controls-grid {height: {$this->agHeight}px; width: {$this->agWidth}px; font: menu; position:relative; overflow:hidden; background-color:white;}");
203 $this->AddAgStyle(".active-controls-grid.gecko {left: 0px;}");
204 $this->AddAgStyle(".active-grid-column {border-right: 1px solid threedshadow;}");
205 $this->AddAgStyle(".active-grid-row {border-bottom: 1px solid threedlightshadow;}");
206 $this->AddAgScript("var $name = new Active.Controls.Grid;");
207 $this->AddAgScript(" $name.setRowProperty(\"count\", $pageSize);");
208 $this->AddAgScript(" $name.setColumnProperty(\"count\", $countColumn);");
209 if (count($this->actions))
210 {
211 $this->AddAgScript(" $name.setDataProperty(\"text\", function(i, j){return (j != 0) ? {$nameData}[i][j-1] : {$nameActions}[i]});");
212 }
213 else
214 {
215 $this->AddAgScript(" $name.setDataProperty(\"text\", function(i, j){return {$nameData}[i][j]});");
216 }
217 $this->AddAgScript(" $name.setColumnProperty(\"text\", function(i){ return {$nameColumns}[i]});");
218 $this->AddAgScript(" $name.setRowHeaderWidth(\"0px\");");
219 $this->AddAgScript(" $name.setColumnHeaderHeight(\"20px\");");
220 $this->AddAgScript(" $name.setAction(\"click\", function(src){window.status = src.getItemProperty(\"text\")});");
221
222 $this->AddAgScript("document.write($name);");
223// $this->AddAgScript(" $name.refresh();");
224// $this->page->OnLoad(" $name.refresh();");
225 }
226
227 function Generate()
228 {
229 $this->GenerateData();
230 $this->GenerateBody();
231 $this->GenerateCommands();
232 $this->page->AddStyleCode($this->agStyle);
233 $script = "<script type=\"text/javascript\">{$this->agScript}</script>\n";
234 $f = new MDiv('', $script, '');
235 return $f->Generate();
236 }
237
238
239}
240?>
GenerateActions(&$ac)
GenerateBody($data)
SetFullWidth($value)
AddAgScript($script)
__construct($data, $columns, $href, $pagelength=15, $index=0)
SetFullHeight($value)
GenerateColumnsHeading($tbl=NULL)
GenerateColumns($tbl=NULL, $row, $i)
AddAgStyle($style)
$action
Definição base.php:4