ypnos-web / cakephp-datatables

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

Set default number of entries? #36

Closed ThomasNucleus closed 7 years ago

ThomasNucleus commented 7 years ago

For options, I have tried specifying the following

    'pageLength' => 100,
    'iDisplayLength' => 100,

At the top of the page, it does have 100 selected. At the bottom it also says "Showing 1 to 100 of 108 entries"

However on the page it still only shows 10 records. Only when I change between the pages does it display 100 entries on a page. Is there another way I should be setting the default number of entries that are displayed?

ypnos-web commented 7 years ago

There is two scenarios here:

Now how to ensure that in the second case? Have a look at the DatatablesComponent configuration:

protected $_defaultConfig = [
        'start' => 0,
        'length' => 10,
        '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
        'comparison' => [], // per-column comparison definition
    ];

So in your example, you would have to set the length option of the component according to your page length.