You need to sign in to do that
Don't have an account?
Shruti Vish
ui:inputselection i m trying to sort the values
<aura:attribute name="ideas" type="Idea[]" />
<ui:inputSelect class=" slds-float--left" label="Sort : " aura:id="selection" change="{!c.onChangeFunction}">
<ui:inputSelectOption text="Trending" label="Trending" value="true" />
<ui:inputSelectOption text="Popular" label="Popular"/>
<ui:inputSelectOption text="Recent" label="Recent"/>
</ui:inputSelect>
onChangeFunction : function(cmp,event){
var selected = cmp.find("selection").get("v.value");
//onsole.log(selected);
if(selected=='Recent')
{
console.log('hi');
var action = cmp.get("c.getIdea1");
action.setCallback(this,function(response){
if (response.getState() === "SUCCESS"){
alert('sqsq');
cmp.set("{!v.ideas}",response.getReturnValue());
}
}
);
}
}
@AuraEnabled
public static List<Idea> getIdea1(){
List<Idea> i=[SELECT Id, Title, Body, CreatedDate FROM Idea order by CreatedDate desc];
System.debug('hi'+i);
return [SELECT Id, Title, Body, CreatedDate FROM Idea order by CreatedDate desc];
}
This is my above code but sort is not happening?
<ui:inputSelect class=" slds-float--left" label="Sort : " aura:id="selection" change="{!c.onChangeFunction}">
<ui:inputSelectOption text="Trending" label="Trending" value="true" />
<ui:inputSelectOption text="Popular" label="Popular"/>
<ui:inputSelectOption text="Recent" label="Recent"/>
</ui:inputSelect>
onChangeFunction : function(cmp,event){
var selected = cmp.find("selection").get("v.value");
//onsole.log(selected);
if(selected=='Recent')
{
console.log('hi');
var action = cmp.get("c.getIdea1");
action.setCallback(this,function(response){
if (response.getState() === "SUCCESS"){
alert('sqsq');
cmp.set("{!v.ideas}",response.getReturnValue());
}
}
);
}
}
@AuraEnabled
public static List<Idea> getIdea1(){
List<Idea> i=[SELECT Id, Title, Body, CreatedDate FROM Idea order by CreatedDate desc];
System.debug('hi'+i);
return [SELECT Id, Title, Body, CreatedDate FROM Idea order by CreatedDate desc];
}
This is my above code but sort is not happening?
you just need to add $A.enqueueAction(action);
nd it will work perfectly please select as best answer if it helped you
All Answers
you just need to add $A.enqueueAction(action);
nd it will work perfectly please select as best answer if it helped you