@@ -119,7 +119,8 @@ public function generateScripts()
119
119
public function generateJson ()
120
120
{
121
121
$ args = array_merge (
122
- $ this ->attributes , [
122
+ $ this ->attributes ,
123
+ [
123
124
'ajax ' => $ this ->ajax ,
124
125
'columns ' => $ this ->collection ->map (function (Column $ column ) {
125
126
$ column = $ column ->toArray ();
@@ -143,6 +144,26 @@ public function parameterize($attributes = [])
143
144
{
144
145
$ parameters = (new Parameters ($ attributes ))->toArray ();
145
146
147
+ $ max_record_per_page = $ this ->config ->get ('datatables.max_record_per_page ' , 0 );
148
+ if (!array_key_exists ('lengthMenu ' , $ parameters )) {
149
+ $ parameters ['lengthMenu ' ] = [10 , 25 , 50 , 100 ];
150
+ }
151
+
152
+ if ($ max_record_per_page != 0 ) {
153
+ $ lengthMenu = array_unique ($ parameters ['lengthMenu ' ]);
154
+ foreach ($ lengthMenu as $ key => $ value ) {
155
+ if ($ value > $ max_record_per_page ) {
156
+ unset($ lengthMenu [$ key ]);
157
+ }
158
+ }
159
+ $ lengthMenu = array_values ($ lengthMenu );
160
+ if (empty ($ lengthMenu )) {
161
+ $ lengthMenu = [$ max_record_per_page ];
162
+ }
163
+ sort ($ lengthMenu );
164
+ $ parameters ['lengthMenu ' ] = $ lengthMenu ;
165
+ }
166
+
146
167
$ values = [];
147
168
$ replacements = [];
148
169
@@ -212,8 +233,10 @@ public function table(array $attributes = [], $drawFooter = false, $drawSearch =
212
233
$ htmlAttr = $ this ->html ->attributes ($ this ->tableAttributes );
213
234
214
235
$ tableHtml = '<table ' . $ htmlAttr . '> ' ;
215
- $ searchHtml = $ drawSearch ? '<tr class="search-filter"> ' . implode ('' ,
216
- $ this ->compileTableSearchHeaders ()) . '</tr> ' : '' ;
236
+ $ searchHtml = $ drawSearch ? '<tr class="search-filter"> ' . implode (
237
+ '' ,
238
+ $ this ->compileTableSearchHeaders ()
239
+ ) . '</tr> ' : '' ;
217
240
$ tableHtml .= '<thead><tr> ' . implode ('' , $ th ) . '</tr> ' . $ searchHtml . '</thead> ' ;
218
241
if ($ drawFooter ) {
219
242
$ tf = $ this ->compileTableFooter ();
0 commit comments