Server-Side Numeric Search Single Digits

Server-Side Numeric Search Single Digits

rbloomquistrbloomquist Posts: 3Questions: 1Answers: 0

Is there a way to update the Individual column searching (text inputs) to search a single digit?

Currently if I search 8 I will get 8, 80, 58, 88, 800, ETC... but I just want it to return the specific number.

I’ve looked at Search API (regular expressions) but can’t get it to work with server side processing.

Any help would be greatly appreciated.

Replies

  • kthorngrenkthorngren Posts: 21,443Questions: 26Answers: 4,974

    Your server script is responsible for searching when using server side processing. Are you using a Datatables provided server side processing script? I don't believe they support regex searching and you will need to add that capability your self. You will want to look at the docs for your data source to see how it handles regex searching and at the performance impact if you use it.

    Kevin

  • rbloomquistrbloomquist Posts: 3Questions: 1Answers: 0

    Thank you. I did this in my server-side script:

    $variable= $_POST["variable"];
    
    ->where( function ( $q ) use ( $variable) { if ( strlen($variable) > 0 ) { $q->where( 'dbcolname', $variable, '=' ); } } )    
    
    

    and then I had to add a data function to the ajax call on my Datatables page to send the post data to my server-side script:

    ajax: {
                url: "URL.php",
                type: "POST",
                data: function (d) {
            d.variable= $('#variable').val();           
                } },
    
    

    and then I had to a add custom input field

     <input type="text" name="variable" id="variable" value="">
    
    

    and some jQuery with a keyup/change function to reload the data.

    $('#variable').on('keyup change', function (){
      
      var variable= $('#variable').val();
      
     myTable.ajax.reload()  
     
     });     
    
    

    Works as expected now. Thank you.

This discussion has been closed.