Okay
  Public Ticket #1641506
Search alphabetically for countries
Closed

Comments

  • junctioncreative started the conversation

    https://www.screencast.com/t/nxEvCzqql is a short video.

    We have a list of countries so when someone types in a few characters - for example type Can for searching for a country  we would Canada to be the first country that comes up not any countries that contain can.

    Looking for ability to start search from the first few letters of a country. 

    Thanks.

  •  472
    Isidora replied

    Hi junctioncreative,
    Thank you for your purchase.

    Sorry for late response. 

    We are located in Serbia and our working time is from 10:00 to 17:00 CET. business days.

    Yes you can, but you have to make some code changes in plugin. In file wp-content/plugins/wpdatatables/source/class.wpdatatable.php around line 1516 you will find this:

    $search .= '`' . $tableName . '`.`' . $aColumns[$i] . "` LIKE '%" . $columnSearch . "%' ";

    and you have to replace it with this:

    $search .= '`' . $tableName . '`.`' . $aColumns[$i] . "` LIKE '" . $columnSearch . "%' ";

    Like this search by the columns will always search values based on search criteria like values are start. It will not search words inside the values like before. This will be affected on all tables and after update you will have to do it again because it will be overwritten.

    Best regards

    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

  • junctioncreative replied

    Thanks for your response.

    We updated the .php file https://www.screencast.com/t/yxpZC8LAxwh but the table still shows values that contain can when we type in Can see short video https://www.screencast.com/t/LiykpwTCWKLT

  •  472
    Isidora replied

    Hi junctioncreative,

    Yes it is not working, because in previous video that you provide you are using column filter not global search of the table. Code that is provided is working for column filters like you requested in previous post. If you need same behavior on global search you have to change code in file wp-content/plugins/wpdatatables/source/class.wpdatatable.php around line 1546 you will find this

    $search .= $this->getLikeExpression($vendor, $leftSysIdentifier . $tableName . $rightSysIdentifier, $leftSysIdentifier . $aColumns[$i] . $rightSysIdentifier, '%' . addslashes($_POST['search']['value']) . '%') . ' OR ';

    And you have to replace with this:

    $search .= $this->getLikeExpression($vendor, $leftSysIdentifier . $tableName . $rightSysIdentifier, $leftSysIdentifier . $aColumns[$i] . $rightSysIdentifier, '' . addslashes($_POST['search']['value']) . '%') . ' OR ';

    Best regards.

    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