ypnos-web / cakephp-datatables

CakePHP3 Plugin for DataTables plug-in for jQuery
MIT License
27 stars 24 forks source link

override length/limit value #28

Closed emnu closed 7 years ago

emnu commented 7 years ago

is there any way i can override length/limit value in

protected $_defaultConfig = [
    'start' => 0,
    'length' => 10, // <-- THIS VALUE
    'order' => [],
    'prefixSearch' => true, // use "LIKE …%" instead of "LIKE %…%" conditions
    'conditionsOr' => [],  // table-wide search conditions
    'conditionsAnd' => [], // column search conditions
    'matching' => [],      // column search conditions for foreign tables
];
ypnos-web commented 7 years ago

Yes. This is standard component config handling. See http://book.cakephp.org/3.0/en/controllers/components.html#configuring-components

emnu commented 7 years ago

thank you for your response, can it being override on the fly? such as

    $data = $this->DataTables->find('Menus', 'threaded', [
        'length' => 100,
    ]);

nevermind, i found it.

    $this->DataTables->config('length', 100);

anyway, thank you.

ypnos-web commented 7 years ago

Sorry for not replying earlier, I was sick. Good to know you could resolve your question!

Please note that DataTables might send a desired length in the request which will then overwrite the configuration value: https://github.com/ypnos-web/cakephp-datatables/blob/master/src/Controller/Component/DataTablesComponent.php#L80