Server Side Processing not honoring searchDelay

Server Side Processing not honoring searchDelay

dshinedshine Posts: 3Questions: 2Answers: 0

My data code looks like this
$(document).ready(function () {
$('#myTable').DataTable({
fixedHeader: true,
ordering: false,
pageLength: 50,
searching: true,
searchDelay: 1000,
processing: true,
serverSide: true,
scrollY: calcDataTableHeight(),
scrollX: true,
ajax : {
url : '/my/url',
type : 'POST'
},
columns: [
{
// column defs here
],
fixedColumns: {
leftColumns: 1
}
});
});

However, a call to the server is made on every key stroke in the search box, not honoring the 1000ms delay that I have specified. What am I doing wrong?

Answers

  • dshinedshine Posts: 3Questions: 2Answers: 0

    here is the code properly formatted

            $(document).ready(function () {
                $('#myTable').DataTable({
                    fixedHeader: true,
                    ordering: false,
                    pageLength: 50,
                    searching: true,
                    searchDelay: 1000,
                    processing: true,
                    serverSide: true,
                    scrollY: calcDataTableHeight(),
                    scrollX: true,
                    ajax : {
                        url : '/my/url',
                        type : 'POST'
                    },
                    columns: [
                        {
                               // column defs here
                    ],
                    fixedColumns: {
                        leftColumns: 1
                    }
                });
            });
    
  • matthttammatthttam Posts: 40Questions: 2Answers: 0

    Today I thought I was experiencing this too. I determined that searchDelay will search on the FIRST keystroke. But then it will wait Xms before checking to see if it needs to try to filter again.

    I set mine to 2000ms and typed abababab repeatedly in the global search while watching the chrome network monitor page. I re-read the searchDelay documentation and this is how it is designed.

    I was hoping for a setting that waited until no changes had occurred for Xms before filtering. Basically "Wait until they are finished typing."

    Your code here looks very close to mine so i wonder if you were experiencing the same thing.

  • allanallan Posts: 63,353Questions: 1Answers: 10,444 Site admin

    I was hoping for a setting that waited until no changes had occurred for Xms before filtering. Basically "Wait until they are finished typing."

    You aren't alone - it comes up fairly frequently. I made a mistake with that one and will probably change this in future.

    Allan

This discussion has been closed.