ServerSide Search Boolean alternative

ServerSide Search Boolean alternative

Pedro MartinsPedro Martins Posts: 22Questions: 11Answers: 0

Hello, a am trying to get search to work on boolean values with ServerSide but can´t seem to find a solution.
Should i just save the true/false as text in database???

Answers

  • rf1234rf1234 Posts: 2,801Questions: 85Answers: 406

    You can create a view that returns the values you want to search for and use it in your editor instance on the server side.
    This approach allows you to return anything just like using a get formatter.
    The advantage is that these values will be found because they come from the database while values returned from a get formatter don't work for server side search.
    An alternative approach is to manipulate the search parameters on the client side before they are sent to the server.

  • rf1234rf1234 Posts: 2,801Questions: 85Answers: 406

    You probably won't need an example for an SQL database view. If you do I can post one.

    Here is an example for search parameter manipulation on the client side. This could work if you have 0 and 1 saved as values for your boolean field in the database. In MySQL this is usually a TINYINT(1) field holding the boolean value.

    ....
    data: function ( d ) {
        if ( d.search.value == 'true' ) {
           d.search.value = 1;
        else if ( d.search.value == 'false' ) {
           d.search.value = 0;
        }
    }
    
This discussion has been closed.