Advanced Search OR by default (v12)

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
alex
User
Posts: 267

Advanced Search OR by default (v12)

Post by alex »

In an older post I have found a nice option of how to force to use OR instead of AND in the Advanced Search when we have 2 operators for a field..

Acc. to Webmaster's suggestion I added the code below to Client Scripts -> Table Specific -> List page -> Startup script:

$(":radio[name^='v_'][value='OR']").prop('checked', true);

Selection to "OR" works but using this server event starting list page displays empty list with "No records found" message so in order to get records it is necessary to push "search" button. I wonder if there is a way to display list page records with preselected advanced search defined values not pushing Search button - as usual?


arbei
User
Posts: 9381

Post by arbei »

Add the code to Startup Script will not affecting the SQL to get the records, double check any code in Recordset_Selecting or Recordset_Searching that will filter all the records.

You can enable the option "Debug" in [Tools] -> [Advanced Settings] to show the SQL that retrieving the records.

Makes sure the SQL are working as your expectation.


alex
User
Posts: 267

Post by alex »

Year I checked "Debug" SQL. The problem is that I need to search using "OR" operator but Advanced Search option by default searches using "AND" operator despite I added the code to Startup Script (as you say it doesn't influence search result).

So the question is how to change search operator "AND" to "OR" for Advanced Search option?


alex
User
Posts: 267

Post by alex »

If manually change in pageinfo.php

$this->delivery_status->AdvancedSearch->SearchConditionDefault = "AND";

to

$this->delivery_status->AdvancedSearch->SearchConditionDefault = "OR";

then it works fine but the question is how to avoid manual changing - to solve the problem by a script.


mobhar
User
Posts: 11720

Post by mobhar »

Try "Recordset_SearchValidated" server event. Please read "Server Events and Client Scripts" topic from PHPMaker Help menu for more info and example.


alex
User
Posts: 267

Post by alex »

year, that worked! Thank you!


Post Reply