Skip to content

Commit 2759fd9

Browse files
committed
Adding checkbox by column position
Adding checkbox by column position ( zero indexed i.e. index starting from 0)
1 parent 296be4f commit 2759fd9

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/Html/Builder.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -460,10 +460,10 @@ public function getQualifiedTitle($title)
460460
* Add a checkbox column.
461461
*
462462
* @param array $attributes
463-
* @param bool $prependColumn
463+
* @param bool $position
464464
* @return $this
465465
*/
466-
public function addCheckbox(array $attributes = [], bool $prependColumn = false)
466+
public function addCheckbox(array $attributes = [], bool $position = false)
467467
{
468468
$attributes = array_merge([
469469
'defaultContent' => '<input type="checkbox" ' . $this->html->attributes($attributes) . '/>',
@@ -477,10 +477,12 @@ public function addCheckbox(array $attributes = [], bool $prependColumn = false)
477477
'width' => '10px',
478478
], $attributes);
479479

480-
if ($prependColumn) {
481-
$this->collection->prepend(new Column($attributes));
480+
if ($position === true) {
481+
$this->collection->prepend($column);
482+
} else if ($position === false || $position >= $this->collection->count()) {
483+
$this->collection->push($column);
482484
} else {
483-
$this->collection->push(new Column($attributes));
485+
$this->collection->splice($position, 0, [$column]);
484486
}
485487

486488
return $this;

0 commit comments

Comments
 (0)