LMSouq
moodle-core Open

Moodle flexible_table sorting

ST
StartVader
1 month ago
3 views
Problem Description
I am using `Moodle 2.6` and already rewrote a table from `html_table` to `flexible_table`. I could not figure out, how the `sorting` is working. I set everything as follows: $table = new flexible_table('Car Bookings'); $table->define_baseurl(new moodle_url("/blocks/cars/view.php")); $table->define_columns(array( 'carname', 'platenumber', 'pickupdate', 'tankdate', 'city', 'actions', )); $table->define_headers(array( 'car name', 'plate number', 'pick-up date', 'tank date', 'city', 'actions', )); $table->sortable(true, 'carname'); $table->collapsible(false); I then add for the sorting: if ($table->get_sql_sort()) { $sort = ' ORDER BY '.$table->get_sql_sort(); } else { $sort = ''; } The table is rendering, but the sorting is not working, i.e the headers are "sorting"-I can click on them, but nothing happens. What I am missing?

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base