yajra/laravel-datatables-html

Add position for Index Col

chrisangle opened this issue · 3 comments

Summary of problem or feature request

Code snippet of problem

// src/Html/Columns/Index.php
public function addIndex(array $attributes = [], $position = false)
    {
        $indexColumn = $this->config->get('datatables.index_column', 'DT_RowIndex');

        $attributes = array_merge([
            'defaultContent' => '',
            'data' => $indexColumn,
            'name' => $indexColumn,
            'title' => '',
            'render' => null,
            'orderable' => false,
            'searchable' => false,
            'exportable' => false,
            'printable' => true,
            'footer' => '',
        ], $attributes);
   
        if ($position === true) {
            $this->collection->prepend($column);
        } elseif ($position === false || $position >= $this->collection->count()) {
            $this->collection->push($column);
        } else {
            $this->collection->splice($position, 0, [$column]);
        }

        return $this;
    }

System details

  • Operating System: Linux
  • PHP Version: 7.2.22
  • Laravel Version: 7.x
  • Laravel-DataTables Version: 9.11
yajra commented

@chrisangle thank you for the suggestion, would you be able to submit a PR for this proposal?

This issue is stale because it has been open for 30 days with no activity.

This issue was closed because it has been inactive for 7 days since being marked as stale.