Okay
  Public Ticket #1533760
Search regular expressions with the Javascript API
Closed

Comments

  • Slim Bouafif started the conversation

    Hello,

    I was working on a project for a client but I encountered a problem with the JS Api.

    I need to search for a regex in a column. I tried this:

    jQuery('#table_1').dataTable().api().column(1).search( 'cas|imp', true, false ).draw()

    but it's not working. When using only .search("cas") or .search("imp"), I get the results I need but not when using a regex.

    This code works with datatables jquery plugin and the documentation of wpdatatables states that wpdatatables is using datatables jquery plugin. https://wpdatatables.com/documentation/information-for-developers/front-end-callbacks/

    What am I doing wrong?

  •  471
    Isidora replied

    HI Slim,
    Thank you for your purchase.

    Sorry for late response,

    Please note that we have a National holiday in our country from Friday 6th to Monday 9th.

    Our plugin is based on Datatables jquery plugin, and you can look about Search API (regular expressions).



    Kind Regards, 

    Isidora Markovic

    wpDataTables: FAQFacebookTwitterFront-end and back-end demoDocs

    Amelia: FAQFacebookTwitter |  Amelia demo sites | Docs

    You can try our wpDataTables add-ons before purchase on these sandbox sites:

    Powerful FiltersGravity Forms Integration for wpDataTablesFormidable Forms Integration for wpDataTables

  • Slim Bouafif replied

    Hello Milan,

    No worries about the delay, I saw the notification. Thanks for you response.

    I already looked at the documentation of Datatables. I even included there librairies to try some stuff. When I initialise the table with their script the exact search work on the same table. But when I use wpDatatable version it does not.

    I made a few tests last night and read the code in wdt.frontend.min.js but could not find why I cant change the search parameters in JS.

    Could that help if I upload an example on a server later today?

    Regards

  • Slim Bouafif replied

    Ok I just figured it out.

    I found out while reverse engineering the plugin that regular expression search does not work when server processing is enabled. The variable

    $_POST['columns'][$i]['search']['regex']
    

    is never used in class.wpdatable.php when filtering is applied. 

    I modified the function queryBasedConstruct based on the code for multiselect type which handle the regex I needed. Nonetheless it would be nice to have a warning in the developer documentation that wpDataTables does not features every functionality of DataTables (like regex search) when server processing is enabled (which is used in the paid version).

    This feature can be really useful when handling very big excel files and a custom frontend.

    Regards

  •  471
    Isidora replied

    HI Slim,

    I am glad that you found a solution.

    We support most of the datatables features which you can find in our documentation.We carefully follow customers requirements and try to implement most of them if they appears in requests from time to time so we will add to our idea list and look into some possible solutions on plugin side for one of next versions.

    Kind Regards, 

    Isidora Markovic

    wpDataTables: FAQFacebookTwitterFront-end and back-end demoDocs

    Amelia: FAQFacebookTwitter |  Amelia demo sites | Docs

    You can try our wpDataTables add-ons before purchase on these sandbox sites:

    Powerful FiltersGravity Forms Integration for wpDataTablesFormidable Forms Integration for wpDataTables