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
edukondalu thodetiedukondalu thodeti 

how to hide and show the results when click on the same button in lightning

i need to hide and show the result when click on the same button,first when i click on the button i need to hide the result and whenever i click on the same button again i need to show the result.i didnot know which component,action to be used for these task.
pls anyone help me i'm new to the lightning
these is my result when i click on the button first time:
User-added imagewhenever i click on the same button again i need to got the result like these
User-added image
Abhishek BansalAbhishek Bansal
Hi Edukondalu,

You can create a boolean variable like showResultSection and on click of the button you can check if this button is false than set it to true and if true than set it to false. Sample code is written below:

.cmp
<aura:attribute name="showResultSection" type="boolean" default="false"/>

<aura:if isTrue="{!v.showResultSection}">
//you can show your list
.......
.....
</aura:if>

<lightning:button label="Show Hide Section" onclick="{! c.handleClick }"/>

Controller
({
    handleClick : function (cmp, event, helper) {
        var showHideVar = cmp.get("v.showResultSection");
        if(showHideVar == false) {
            cmp.set("v.showResultSection", true);
        }
        else {
            cmp.set("v.showResultSection", false);
        }
    }
});

Please take care of the syntax errors and let me know if you need any further help on this.

Thanks,
Abhishek Bansal. ​​​​​​​