Reset full search

Reset full search

sairus95sairus95 Posts: 5Questions: 2Answers: 0

hello, I created a button outside the table to erase all searches, it works but very long around 6s. Do you have a solution to optimize thank you

        
dom: "<'row'<'col-lg-4 col-sm-12'l><'col-lg-2 col-sm-12 d-flex justify-content-center reset'><'col-lg-2 col-sm-12 d-flex justify-content-center resetReorderCol'><'col-lg-4 col-sm-12'f>>"+"<'row'<'col-lg-12 col-sm-12'tr>>"+"<'row'<'col-lg-4 col-sm-12'B><'col-lg-4 col-sm-12 d-flex justify-content-center'i><'col-lg-4 col-sm-12 d-flex justify-content-center'p>>",
            
$('#tableTool_wrapper button.btn.btn-danger.clearSearch').click(function() {
  $('#tableTool_filter input').focus().select().val('');
     table
     .search('')
     .draw();
});

Answers

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    You can drop line 4, and just use search() as that'll clear the input element as well.

    If that doesn't help, we're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • sairus95sairus95 Posts: 5Questions: 2Answers: 0
  • kthorngrenkthorngren Posts: 20,142Questions: 26Answers: 4,736

    Colin was asking for a link to a running test case to debug why it takes 6 seconds to reset the search. the problem might be due to the amount of data or something else occurring on your page.

    Kevin

  • tangerinetangerine Posts: 3,342Questions: 35Answers: 394

    Your example doesn't run. You don't appear to have included jQuery.

  • sairus95sairus95 Posts: 5Questions: 2Answers: 0

    I included jquery

    there are 700 rows and 23 columns in the table
    the longest is the deletion in the selects

  • kthorngrenkthorngren Posts: 20,142Questions: 26Answers: 4,736
    edited November 2021

    I included jquery

    The include statements are in the wrong order because you are getting this error:

    dataTables.colReorder.js:46 Uncaught ReferenceError: jQuery is not defined

    the longest is the deletion in the selects

    The code you posted above is only clearing the global search, not including the select column searches. You are using the YADCF column search library. How are you clearing those? For issues specific to YADCF please contact the developer of the library.

    Again for help please provide a running test case that shows the issue with steps of how to recreate the issue.

    Kevin

Sign In or Register to comment.