5-1-4-4. Set Value in Search Condition on Search Template

Set “this month” in month field which has no value when search button is pressed. This method requires a month field (picklist with 1-12 value) in search condition on search template. Also add an empty record with 31 columns if there is no selected month data.

Apex class for extending page : SkyEditorClass
"ID" property of the target DataTable : dataTableSet1

global class MyExtender extends SkyEditor2.Extender {
    SkyEditorClass extension;
    SkyEditorClass.dataTableSet1 monthlyReports;

	public MyExtender(SkyEditorClass extension) {
        this.extension = extension;
        this.monthlyReports = extension.dataTableSet1;
    }

	global override void init(){
        String accountId = ApexPages.currentPage().getParameters().get('accid');
        extension.Component1_val.accountLink__c = accountId;
//      // [Relax the FLS] for checking
//      extension.Component1_val.SkyEditor2__Text__c = accountId;
//      extension.Component1_val.SkyEditor2__Textarea__c
//           = [SELECT Name FROM Account Where id = :accountId].Name;
        extension.Component1_op.value = 'eq';
 
        extension.doSearch();
    }

	global override void preSearch(){
        if (extension.Component2_val.month__c == '') {
            extension.Component2_val.month__c  
            = String.valueOf(Date.today().month());
            extension.Component2_op.value = ‘eq’;
        }
    }
    global override void afterSearch() {
        if (monthlyReports.items.size() <= 0) {
            for (Integer i = 0; i < 31 ; i++) {
                this.monthlyReports.add();
            }
        }
    }
    // TestMethod
    private static testMethod void testMyExtender() {
        Account acc = new Account(Name='Test');
        insert acc;
        SkyEditorClass ext = new SkyEditorClass(new ApexPages.StandardController(acc));
        MyExtender extender = new MyExtender(ext);
        ext.doSearch();
    }
}