Skip to content
This repository has been archived by the owner on Feb 4, 2023. It is now read-only.

Add colReorder extension #815

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions Datatable/Extensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ class Extensions
*/
protected $rowGroup;

/**
* The ColReorder Extension.
* Reorder columns
* Default: null
*
* @var null|bool
*/
protected $colReorder;

//-------------------------------------------------
// Ctor.
//-------------------------------------------------
Expand Down Expand Up @@ -99,12 +108,14 @@ public function configureOptions(OptionsResolver $resolver)
'responsive' => null,
'select' => null,
'row_group' => null,
'col_reorder' => null,
));

$resolver->setAllowedTypes('buttons', array('null', 'array', 'bool'));
$resolver->setAllowedTypes('responsive', array('null', 'array', 'bool'));
$resolver->setAllowedTypes('select', array('null', 'array', 'bool'));
$resolver->setAllowedTypes('row_group', array('null', 'array', 'bool'));
$resolver->setAllowedTypes('col_reorder', array('null', 'bool'));

return $this;
}
Expand Down Expand Up @@ -228,4 +239,27 @@ public function setRowGroup($rowGroup)

return $this;
}

/**
* Get colReorder.
*
* @return null|bool
*/
public function getColReorder()
{
return $this->colReorder;
}

/**
* Set colReorder.
*
* @param null|bool
* @return $this
*/
public function setColReorder($colReorder)
{
$this->colReorder = $colReorder;

return $this;
}
}
27 changes: 27 additions & 0 deletions Resources/doc/extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
2. [Responsive](#2-responsive)
3. [Select](#3-select)
4. [RowGroup](#4-rowgroup)
5. [ColReorder](#4-colreorder)

## 1. Buttons

Expand Down Expand Up @@ -360,3 +361,29 @@ With the RowGroup class you can set the following options, for details see the [
| endRender | array or null | null | Provide a function that can be used to control the data shown in the end grouping row. |
| startRender | array or null | null | Provide a function that can be used to control the data shown in the start grouping row. |
___


## 5. ColReorder

**Be sure to install the [ColReorder Extension](https://datatables.net/extensions/colreorder/) before using.**

### Template

@SgDatatables/datatable/extensions.html.twig

### Initialisation

Just add `col_reorder` to your extensions options with the value `true`:

``` php
public function buildDatatable(array $options = array())
{
// ...

$this->extensions->set(array(
'col_reorder' => true,
));

// ...
}
```
5 changes: 5 additions & 0 deletions Resources/views/datatable/extensions.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,9 @@
startClassName: '{{ sg_datatables_view.extensions.rowGroup.startClassName }}'
{% endif %}
},
{% endif %}

{# ColReorder Extension #}
{% if sg_datatables_view.extensions.colReorder is same as(true) %}
colReorder: true,
{% endif %}