Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Datatable js Search Server side after time or word length

                initComplete: function() {
                    var api = this.api();
                    var searchWait = 0;
                    var searchWaitInterval;
                    // Grab the datatables input box and alter how it is bound to events
                    $(".dataTables_filter input")
                        .unbind() // Unbind previous default bindings
                        .bind("input", function(e) { // Bind our desired behavior
                            var item = $(this);
                            searchWait = 0;
                            if(!searchWaitInterval) searchWaitInterval = setInterval(function(){
                                searchTerm = $(item).val();
                                // if(searchTerm.length >= 3 || e.keyCode == 13) {
                                clearInterval(searchWaitInterval);
                                searchWaitInterval = '';
                                // Call the API search function
                                api.search(searchTerm).draw();
                                searchWait = 0;
                                // }
                                searchWait++;
                            },2000);
                            return;
                        });
                },
 
PREVIOUS NEXT
Tagged: #Datatable #js #Search #Server #side #time #word #length
ADD COMMENT
Topic
Name
3+8 =