0

私はセールスフォース照明アプリケーション開発に非常に慣れていません。雷アプリで機能を作成する際に、あなたの助けを求めています。すべてのアカウントを Lightning コンポーネントにロードしたので、Billing City 名をクリックして、BillingCity を使用してレコードをフィルタリングする必要があります。請求先の都市をクリックすると、その都市に関連するすべてのアカウントが表示され、特定の条件を除くすべてのレコードをロードするクリア フィルター イメージ (ここでは黒丸を使用) をクリックしてフィルターをクリアできます。

助けてください !!!

Lightning アプリケーションのメインページ

ページのスクリーンショット

AccountMainScreen.cmp

<aura:component controller="AccountController">
    <aura:attribute name="allaccounts" type="List" description="All Products" />
    <aura:handler name="init" value="{!this}" action="{!c.fillAccount}"/>
    <div class="container">
        <div style="font-weight: bold;">Filter by Billing City</div><br/>
        <div>Bangalore</div><br/>
        <div>Mountain View</div><br/>
        <div>Singapore</div><br/>
        <div>
        <div style="background-color: #7f7e8a;height: 20px;"></div>    
        <aura:iteration items="{!v.allaccounts}" var="account">
            <article class="slds-card">
            <div class="slds-card__header slds-grid">
             <header class="slds-media slds-media--center slds-has-flexi-truncate">
              <div class="slds-media__body slds-truncate">
        <h2>
          <a href="javascript:void(0);" class="slds-text-link--reset">
            <span class="slds-text-heading--small">{!account.Name}</span>
          </a>
        </h2>
      </div>
    </header>
  </div>
  <div class="slds-card__body">{!account.BillingCity}</div>

</article>
        </aura:iteration>
        </div>

    </div>   

</aura:component>

AccountController.apxc

public class AccountController {

    @AuraEnabled
    public static List<Account> getAllAccounts()
    {

        List<Account> lstacc=[select Name,BillingCity from Account where BillingCity != null];
        return lstacc;

    }

}

AccountMainScreenController.js

 ({     fillAccount : function(component, event, helper) {
        helper.getAccountsfromSF(component, event)  } })

AccountMainScreenHelper.js

({
    getAccountsfromSF : function(component, event) {

        var action = component.get('c.getAllAccounts');
        action.setCallback(this,function(actionResult){
        component.set('v.allaccounts', actionResult.getReturnValue());           
        });
        $A.enqueueAction(action);    

    }
})
4

1 に答える 1

0

SOQL クエリ内でフィルタリングすることをお勧めします。

それ以外の場合は、JS で属性を編集できます。 <aura:attribute name="allaccounts" type="List" description="All Products" />

たとえば、アイテムを除外したい場合は、次のようにすることができます。

var itemList = component.get("v.allAccounts");
var newList = [];
for (var item of ItemList){
  if(item.property === condition){
    newList.push(item);
}
component.set('v.allAccounts',newList);

それはうまくいきますが、最善の方法でやりたい場合は、適切なマップ、フィルター、reduce 関数を JavaScript で使用できます。

于 2017-01-24T23:00:01.167 に答える