function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Thirumagal SiluvaithasanThirumagal Siluvaithasan 

Selector Pattern in Lightning Component

Hi All, 

I have implemented a search button click function to retrieve and fetch data into table in lightning component.
 
@AuraEnabled
    public static List < Data_Import__c > fetchdata(String statuskey,String versionkey) {
        String status = statuskey;
        String version = versionkey;
        List <Data_Import__c> returnList = new List <Data_Import__c>();
        for (Data_Import__c dataim: [SELECT Name,Error_message__c,version__c,Status__c FROM Data_Import__c WHERE Status__c =: status AND version__c =: version]) {
            returnList.add(dataim);
        }
        return returnList;
    }
 
Search: function(component, event, helper) {
       helper.SearchHelper(component, event);
        
  }

SearchHelper: function(component, event) {
        var action = component.get("c.fetchdata");
        action.setParams({
            'statuskey': component.find("statusId").get("v.value"),
            'versionkey': component.find("versionId").get("v.value")
        });

and its working fine. Now I want to do the same thing using selector pattern.I want to change the code using selector pattern. Can anyone please help me to implement this.

Thank you. 
 
MagulanDuraipandianMagulanDuraipandian
Yes. Call the selector methods inside fetchData(). The returnList should return list < Data_Import__c > data.