0

特定のフィルター条件に基づいて、Fiori アプリの詳細ページで承認/拒否ボタンを非表示にしようとしています。フィルターは、ビュー/コントローラー拡張機能を介してマスター リスト ビュー (左側のビュー) に追加されます。ここで、ユーザーが特定のタイプのフィルター (過去の注文など) を選択した場合、承認/拒否ボタンは注文の詳細ページに表示されません。これは、ヘッダー/詳細ビューでボタンを定義した方法です

 this.oHeaderFooterOptions = {
                       oPositiveAction: {                       
                        sI18nBtnTxt: that.resourceBundle.getText("XBUT_APPROVE"),
                        id :"btn_approve",
                        onBtnPressed: jQuery.proxy(that.handleApprove, that)
                       },

                   oNegativeAction: {                   
                    sI18nBtnTxt: that.resourceBundle.getText("XBUT_REJECT"),
                    id :"btn_reject",
                    onBtnPressed: jQuery.proxy(that.handleReject, that)
                   },

ただし、実行時には、これらのボタンには前述の ID が割り当てられず、代わりに __button0 および __button1 の ID で作成されます。

これらのボタンをマスター リスト ビューから非表示にする方法はありますか?

ありがとうございました。

4

3 に答える 3

1

コントローラーで setHeaderFooterOptions を複数回呼び出すことができます。

//Code inside of the controller
_myHeaderFooterOptions = {
    oPositiveAction: {                       
        sI18nBtnTxt: that.resourceBundle.getText("XBUT_APPROVE"),
        id :"btn_approve",
            onBtnPressed: jQuery.proxy(that.handleApprove, that)
        },
    oNegativeAction: {                   
        sI18nBtnTxt: that.resourceBundle.getText("XBUT_REJECT"),
        id :"btn_reject",
        onBtnPressed: jQuery.proxy(that.handleReject, that)
    }
},

//set the initial options
onInit: function () {
    this.setHeaderFooterOptions(this._myHeaderFooterOptions);
},

//modify the options in an event
onFilter : function () {
    //remove the negative action to hide it
    this._myHeaderFooterOptions.oNegativeAction = undefined;
    this.setHeaderFooterOptions(this._myHeaderFooterOptions);
},

//further code

_myHeaderFooterOptions を操作することで、表示されるボタンに影響を与えることができます。

于 2014-10-06T14:28:22.660 に答える
-1

まず、 HeaderFooterOptions を定義するときsIdに代わりに使用する必要があります。たとえば、承認ボタンでidフッター ボタンを取得できます。sId

this._oControlStore.oButtonListHelper.mButtons["btn_approve"]

次のコード スニペットを確認してください。

S2.view.controller:次のように定義されたフィルター イベント ハンドラーがあり、EventBusを使用してイベントOrderTypeChanged をに発行しS3.view.controllerます。

onFilterChanged: function(oEvent) {
    // Set the filter value, here i use hard code
    var sFilter = "Past Orders";
    sap.ui.getCore().getEventBus().publish("app", "OrderTypeChanged", {
         filter: sFilter
    });
}

S3.view.controller :OrderTypeChangedからイベントをサブスクライブしS2.view.controllerます。

onInit: function() {
    ///
    var bus = sap.ui.getCore().getEventBus();
    bus.subscribe("app", "OrderTypeChanged", this.handleOrderTypeChanged, this);

},

getHeaderFooterOptions: function() {

    var oOptions = {

        oPositiveAction: {
            sI18nBtnTxt: that.resourceBundle.getText("XBUT_APPROVE"),
            sId: "btn_approve",
            onBtnPressed: jQuery.proxy(that.handleApprove, that)
        },

        oNegativeAction: {
            sI18nBtnTxt: that.resourceBundle.getText("XBUT_REJECT"),
            sId: "btn_reject",
            onBtnPressed: jQuery.proxy(that.handleReject, that)
        }
    };
    return oOptions;

},
handleOrderTypeChanged: function(channelId, eventId, data) {
    if (data && data.filter) {
        var sFilter = data.filter;
        if (sFilter == "Past Orders") {
            this._oControlStore.oButtonListHelper.mButtons["btn_approve"].setVisible(false);
        }
        //set Approve/Reject button visible/invisible based on other values 
        //else if(sFilter == "Other Filter") 
    }
}
于 2014-10-08T08:29:08.367 に答える