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
ChinnoyChinnoy 

how to filter the data based on the selection?

Hi 

I am getting the data from response.Now i have to filter the data based on the picklist selection.

Note: i am not using any object.

Thanks
Deepali KulshresthaDeepali Kulshrestha
Hi Venkat,  

You can filter the list and show the filtered list in the UI like this:
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    
    <aura:attribute name="DataList" type="List" />
    <aura:attribute name="FilteredDataList" type="List" />
    
    <lightning:select name="Picklist" label="Status" onchange="{!c.onChange}">
    </lightning:select>
</aura:component>

js Controller:

({
    onChange: function (cmp, event, helper) {
        var selPickListValue = event.getSource().get("v.value");
        var filteredList=[];
        var dataList = component.get("v.DataList");
        
        for(var i=0;i<dataList.length;i++){
            if(dataList[i] == selPickListValue)
                filteredList.push(dataList[i]);
        }
        if(filteredList.length>0)
            component.set("v.FilteredDataList",filteredList);
        }  
})


I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com
ChinnoyChinnoy
Hey Deepali,

Thanks for the reply.

What about the controller class? and i said i need consume with out an object.