Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.
Closed
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
39 changes: 39 additions & 0 deletions Datatable/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ class Options
// These 'null' initialized options uses the default value of the DataTables plugin.
//--------------------------------------------------------------------------------------------------

/**
* Give the possibility to change the order of the columns
* DataTables default: false
* Default: null
*
* @var null|bool
*/
protected $colReorder;

/**
* Delay the loading of server-side data until second draw.
* DataTables default: null
Expand Down Expand Up @@ -268,6 +277,7 @@ public function __construct()
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'col_reorder' => null,
'defer_loading' => null,
'display_start' => null,
'dom' => null,
Expand All @@ -293,6 +303,7 @@ public function configureOptions(OptionsResolver $resolver)
'global_search_type' => 'like',
));

$resolver->setAllowedTypes('col_reorder', array('null', 'bool'));
$resolver->setAllowedTypes('defer_loading', array('null', 'int', 'array'));
$resolver->setAllowedTypes('display_start', array('null', 'int'));
$resolver->setAllowedTypes('dom', array('null', 'string'));
Expand Down Expand Up @@ -327,6 +338,34 @@ public function configureOptions(OptionsResolver $resolver)
// Getters && Setters
//-------------------------------------------------

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

return $this->colReorder;
}

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

return $this;
}

/**
* Get deferLoading.
*
Expand Down
1 change: 1 addition & 0 deletions Resources/doc/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ With 'null' initialized options uses the default value of the DataTables plugin.

| Option | Type | Default | Description |
|-------------------------------|--------------------|-----------|-------------|
| col_reorder | null or bool | null | Allow the reordering of columns. |
| defer_loading | null, int or array | null | Delay the loading of server-side data until second draw. |
| display_start | null or int | null | Initial paging start point. |
| dom | null or string | null | Define the table control elements to appear on the page and in what order. |
Expand Down
3 changes: 3 additions & 0 deletions Resources/views/datatable/options.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
# For the full copyright and license information, please view the LICENSE
# file that was distributed with this source code.
#}
{% if sg_datatables_view.options.colReorder is not same as(null) %}
"colReorder": {{ sg_datatables_view.options.colReorder|sg_datatables_bool_var }},
{% endif %}
{% if sg_datatables_view.options.deferLoading is not same as(null) %}
"deferLoading": {{ sg_datatables_view.options.deferLoading }},
{% endif %}
Expand Down