2

Hi I want to disable the button. in the code where I had written part there I'am trying to disable the button.In java script I didn't write any logic ..check attribute there i used disable functionality logic.

<aura:component controller="AlloactionController" implements="force:appHostable,force:lightningQuickAction,flexipage:availableForRecordHome,flexipage:availableForAllPageTypes,force:hasRecordId" access="global">
<aura:attribute name="isdisplay" type="boolean" default="false"/>
<aura:attribute name="emplst" type="Employee__c[]"/>
<aura:attribute name="name" type="string"/>
<aura:attribute name="disabled" type="boolean" default="false" />
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<table class="slds-table slds-table--bordered slds-table--cell-buffer">
    <thead>
        <tr class="slds-text-title--caps">
            <th  scope="col"><div class="slds-truncate"> employee Name</div></th>
            <th  scope="col"> <div class="slds-truncate">employee Id</div></th>
            <th  scope="col"> <div class="slds-truncate">FBP allocation</div></th>
            <th  scope="col"><div class="slds-truncate">TotalFBPallocation</div></th>

        </tr>
    </thead>
    <tbody>
        <aura:iteration items="{!v.emplst}" var="emp">

            <tr>
                <td  class="cell">  <p>
                    {!emp.Name}
                    </p>
                </td>
                <td  class="cell">  <p>
                    {!emp.Id}
                    </p>
                </td>
                <td  class="cell"><p>
                    {!emp.FBP_Allocation_Limit_per_Year__c}
                    </p></td>
                <td  class="cell"><p>
                    {!emp.Total_FBP_Allocations_This_Year__c}
                    </p>
                </td>
                <aura:if isTrue="{!(emp.FBP_Allocation_Limit_per_Year__c> emp.Total_FBP_Allocations_This_Year__c)}">
                    <td  class="cell"> <p><lightning:button variant="brand" label="FBP Allocation" onclick="{!c.VfpageCall}" name="{!emp.Id}"  /></p></td>
                    <aura:set attribute="else">
                        <td  class="cell"> <p><lightning:button  class="btnCls" variant="brand" disabled="{!v.disabled}" label="FBP Allocation"/></p></td>
                    </aura:set> 
                </aura:if>

            </tr>
        </aura:iteration>
    </tbody>
</table>

  • Is the button always enabled or disabled? – itzmukeshy7 Apr 27 '17 at 6:22
  • no..no..that button always has to be disabled... – user44385 Apr 27 '17 at 6:27
  • 4
    Then why are you adding that button on UI? Or you still want to add that button and want it disabled always, try this <lightning:button class="btnCls" variant="brand" disabled="true" label="FBP Allocation" /> no need to use any variable. – itzmukeshy7 Apr 27 '17 at 6:30
  • thank you @its works for me...I used the variable but that time i didnt work ..why whats the reason? – user44385 Apr 27 '17 at 6:31
  • i Added that button for client understanding In ui only he comes to know right ..just for his reference tats it – user44385 Apr 27 '17 at 6:42
4

If you want to make the button always hidden then why are you adding that button on UI? Or you still want to add that button and want it disabled always, try this:

 <lightning:button class="btnCls" variant="brand" disabled="true" label="FBP Allocation" />

no need to use any variable and if you want to use variable then set the default value to true:

<aura:attribute name="isDisabled" type="Boolean" default="true" />
<!-- More code if any -->
<lightning:button class="btnCls" variant="brand" disabled="{!v.isDisabled}" label="FBP Allocation" />
|improve this answer|||||
0

You can use disabled="true". So the button becomes as follows :

<lightning:button  class="btnCls" variant="brand" disabled="true" label="FBP Allocation"/>
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.