[Koha-bugs] [Bug 24561] Add a datatables API wrapper

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Mon Apr 27 05:01:27 CEST 2020


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24561

--- Comment #10 from Tomás Cohen Arazi <tomascohen at gmail.com> ---
Created attachment 103727
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=103727&action=edit
Bug 24561: Add a Datatables api wrapper that implements filter and order
embedded columns

This patch adds the ability to filter and order by embedded columns.

To use it you must in JS:

$('datatable_selector').api({datatables_options})

where datatables_options are all datatables options plus:

1. embed: [list of embeddable tables]
   This option adds x-koha-embed header to request.

2. header_filter: true|false
   This option if true sets x-koha-query header with stringyfied json of
filters

Oderable and searchable columns must define data option as string, otherwise
filter and order won't be possible.
If you must custom the output, use the render function.

For example:

* Don't

> $('.table_selector').api({
>   columns: [
>     {
>       data: function(row, type, val, meta) {
>         return '<a href="'+row.link+'">'+row.holds.patron.firstname+'</a>';
>       },
>       orderable: true,
>       searchable: true
>     }
>   ]
> });

* Do

> $('.table_selector').api({
>   columns: [
>     {
>       data: 'holds.patron.firstname',
>       render: function(row, type, val, meta) {
>         return '<a href="'+row.link+'">'+row.holds.patron.firstname+'</a>';
>       },
>       orderable: true,
>       searchable: true
>     }
>   ]
> });

To test you must implement and test bug 20936, where it will be used.

Signed-off-by: Kyle M Hall <kyle at bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen at theke.io>

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list