]> git.koha-community.org Git - koha.git/commit
Bug 24561: Add a Datatables api wrapper that implements filter and order embedded...
authorAgustin Moyano <agustinmoyano@theke.io>
Wed, 19 Feb 2020 14:33:14 +0000 (11:33 -0300)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Tue, 12 May 2020 10:39:16 +0000 (11:39 +0100)
commit4b37a4e8d3f93404f796a4edbfacb8b7a737c0ae
tree1f352dc5b1a8b5eb6682b48e0ff095845ca71d53
parent3f546c031ab4557fb6bf98342cc3b8dfe870e11d
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@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
koha-tmpl/intranet-tmpl/prog/js/datatables.js
koha-tmpl/opac-tmpl/bootstrap/js/datatables.js