- 🇫🇷France Chris64 France
A real problem exists here. And the arguments of the related issue #3131305: Default Sort Order Not Working → are right,
The Default sort order does not work because the code continually resets the aaSorting to an empty array as it loops over each field, so only the last column could be default sorted.
Should be changed the inside loop code,
// Set default sort order. $datatable_options['aaSorting'] = []; if ($options['default'] == $field) { $datatable_options['aaSorting'] = [[$position, $options['order']]]; }
puting
$datatable_options['aaSorting'] = [];
out of the loop. Enough. Although necessary.$datatable_options['aaSorting']
is a global information to the table. If no column is chosen as default$options['default']
is set to-1
and never match$field
, meaning$datatable_options['aaSorting']
need to be initialized. If a column is chosen (only one since radio button)$options['default'
] is set to the corresponding field name and one match exists in the loop.Also possible the change,
$datatable_options['aaSorting'] = [[$position, $options['order']]];
->
$datatable_options['aaSorting'][] = [$position, $options['order']];
In this way some thing wrong in the$datatable_options['aaSorting']
processing is more visible. - Status changed to Needs work
about 1 year ago 8:27pm 10 November 2023 - 🇩🇪Germany Anybody Porta Westfalica
Changes LGTM @Chris64. Could you please prepare this as MR?
- Status changed to Needs review
about 1 year ago 7:04pm 18 November 2023 - Status changed to RTBC
about 1 year ago 8:29am 20 November 2023 - 🇩🇪Germany Anybody Porta Westfalica
RTBC for MR!15 - thank you @Chris64. Final test by maintainer.
- 🇫🇷France dqd London | N.Y.C | Paris | Hamburg | Berlin
@Chris64: is the related issue fixed by this patch too? (Extraordinay contribution by the way @Chris64 and @Anybody, I added a credit section for special thanks and listed you both on the project page.)
- Status changed to Fixed
11 months ago 8:02pm 17 January 2024 - 🇫🇷France dqd London | N.Y.C | Paris | Hamburg | Berlin
Merged and queued for upcoming release.
- 🇫🇷France Chris64 France
@diqidoq, the related issue #3014926 → is from the 7.x-1.x-dev version, and the code is a little different. But it is the same problem in the code, as noted by @Anybody. This patch does not apply to the 7.x version.
- 🇫🇷France dqd London | N.Y.C | Paris | Hamburg | Berlin
Ah yes, of course... Sorry I missed the different version. Then all is self explanatory. Thanks!
Awesome contributions @Chris64. I'll think already about how to embrace your comittment to the Drupal community. +1
Automatically closed - issue fixed for 2 weeks with no activity.