Modifying report to sort results - olszowka/Zambia GitHub Wiki

Report sorting uses DataTables (https://datatables.net).

In order to enable and configure DataTables for a report (which adds sorting, paging, etc.) do the following:

  1. Add id="reportTable" to the main table element of the report.
  2. Surround header rows of table with <thead></thead> element and body rows with <tbody></tbody> element.
  3. Add $report['columns'] = array(...) to the specification of the report. There must be an element of this array for each column in the table, though null is an acceptable element.
  4. Configure a column by making a subarray for the column (as a element of the array above)
  5. Example options are "visible", "orderable", "orderData", "Width" 6, See options.columns in https://datatables.net/reference/option/ for more details

Example:

$report['columns'] = array(
    null,
    null,
    null,
    array("orderData" => 4),
    array("visible" => false),
    array("orderData" => 6),
    array("visible" => false),
    null
);

Columns are numbered starting at 0. Column 3 will be sorted by the data in Column 4, and column 4 won't be visible. This is useful for sorting a date time presented like "Friday 3:00pm".

⚠️ **GitHub.com Fallback** ⚠️