5-1-4-12 Add Search Condition
You can add optional search condition to Search Template.
In this sample code, we assume that the search condition 'conditionValue' is input by AppComponent and the search result table ID was changed to 'resultTable'.
Apex class for extending page : SearchConditionSample
global with sharing class SearchConditionSampleExtender extends SkyEditor2.Extender{ SearchConditionSample ext; //Search condition value public String conditionValue {get; set;} private MyQueryListener myListner; public SearchConditionSampleExtender(SearchConditionSample extension){ this.ext = extension; } public override void init(){ System.debug('init:'); myListner = new MyQueryListener(); //Get QueryMap by the ID of Search Result table ext.QueryMap.get('resultTable'). addListener(myListner); } public override void preSearch(){ // Add if it is set for the search condition if(String.isBlank(conditionValue)){ myListner.setMyWhereClause(null); }else{ String sWhere = 'text__c = ' + conditionValue; myListner.setMyWhereClause(sWhere); } } // QueryListener is the interface to extend search actions of SkyVisualEditor, which enables to add query. public class MyQueryListener implements SkyEditor2.QueryListener{ private string myWhereClause; public void setMyWhereClause(String s){ myWhereClause = s; } public void apply(SkyEditor2.Query query){ if(String.isNotBlank(myWhereClause)){ query.addWhereIfNotFirst('AND'); query.addWhere(myWhereClause); } } } }
, multiple selections available,