[Koha-bugs] [Bug 35284] No more delay between 2 DT requests

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Thu Nov 23 15:14:36 CET 2023


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

Lari Strand <lmstrand at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lmstrand at gmail.com

--- Comment #37 from Lari Strand <lmstrand at gmail.com> ---
I resolved the issue (in 22.11 without these patches) by setting a timeout in
koha-tmpl/intranet-tmpl/prog/js/datatables.js that waits after typing has
finished to the column filter field before filtering happens. This way we do
not need to limit the amount of events fired (throttling) and the system feels
responsive at all times, even with heavy filtering going on and lots of typing
to the filter field.

                    function delay(callback, ms) {
                        var timer = 0;
                        return function() {
                          var context = this, args = arguments;
                          clearTimeout(timer);
                          timer = setTimeout(function () {
                            callback.apply(context, args);
                          }, ms || 0);
                        };
                      }

                    $( input_type, this ).on( 'keyup change', (delay(function
() {
                        if ( table_dt.column(i).search() !== this.value ) {
                            if ( input_type == "input" ) {
                                table_dt
                                    .column(i)
                                    .search( this.value )
                                    .draw();
                            } else {
                                table_dt
                                    .column(i)
                                    .search( this.value.length ?
'^'+this.value+'$' : '', true, false )
                                    .draw();
                            }
                        }
                    },500 )));

Something among those lines. 500ms at the bottom is a hardcoded wait time until
the keyup or change event fires for which the value could be fetched from
somewhere else is hard coding is an issue. Could this be a suitable/better
approach still for filtering columns?

I'm also wondering why we haven't updated the version of the Datatables
libraries. Should it be updated? We have 4 years of commits missing. 1.13.8
seemed to work out of the box on my dev install of 22.11.

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


More information about the Koha-bugs mailing list