Skip to content

Commit 52aac10

Browse files
committed
misc
1 parent dfa8a92 commit 52aac10

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

src/Grid/Grid.php

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,16 @@ public function addRow(array $attrs = [], int|bool $special = self::ROW_NORMAL):
215215
return $this;
216216
}
217217

218+
public function addHeaderRow(array $attrs = []): static
219+
{
220+
return $this->addRow($attrs, static::ROW_HEAD);
221+
}
222+
223+
public function addFooterRow(array $attrs = []): static
224+
{
225+
return $this->addRow($attrs, static::ROW_FOOT);
226+
}
227+
218228
/**
219229
* Method to get the attributes of the currently active row
220230
*
@@ -286,14 +296,24 @@ public function setActiveRow(int $id): static
286296
*/
287297
public function setRowCell(string $name, string $content, array $attrs = [], bool $replace = true): static
288298
{
289-
if ($replace || !isset($this->rows[$this->activeRow][$name])) {
299+
return $this->setDirectlyRowCell($this->activeRow, $name, $content, $attrs, $replace);
300+
}
301+
302+
public function setDirectlyRowCell(
303+
int $row,
304+
string $name,
305+
string $content,
306+
array $attrs = [],
307+
bool $replace = true
308+
): static {
309+
if ($replace || !isset($this->rows[$row][$name])) {
290310
$cell = new stdClass();
291311
$cell->attribs = $attrs;
292312
$cell->content = $content;
293-
$this->rows[$this->activeRow][$name] = $cell;
313+
$this->rows[$row][$name] = $cell;
294314
} else {
295-
$this->rows[$this->activeRow][$name]->content .= $content;
296-
$this->rows[$this->activeRow][$name]->attribs = $attrs;
315+
$this->rows[$row][$name]->content .= $content;
316+
$this->rows[$row][$name]->attribs = $attrs;
297317
}
298318

299319
return $this;

0 commit comments

Comments
 (0)