-1

expert.

I use the API 「sap.ui.comp.varinats」 to implement variant management.
Save the variant data to S/4 via OData.

The "SAVE" button is invisible, so I want to enable it.
I referred to the article below, but it didn't work.
https://answers.sap.com/questions/12086627/variant-management---save-option.html

I want to enable this "SAVE" button when the view has finished loading, but I have a problem.
I want to get the oVariantSave function using this.getView().ById("vm").
I can get the oVariantSave function in onSelect.
But I can't get the oVariantSave function in onAfterRendering.
enter image description here
enter image description here

<View>
<mvc:View xmlns:mvc="sap.ui.core.mvc" 
    xmlns:v="sap.ui.comp.variants" 
    controllerName="Test.controller.View1" displayBlock="true">
    <App id="app">
        <Page id="page" title="{i18n>title}">
            <content>
                <v:VariantManagement id="vm" select="onSelect" save="onSave" enabled="true" manage="onManage" showExecuteOnSelection="false"
                    showShare="false" showSetAsDefault="false" variantItems="{Variants>results}">
                    <v:variantItems>
                        <v:VariantItem text="{Variants>Varname}" key="{Variants>Varkey}" author="{Variants>Userid}"/>
                    </v:variantItems>   
                </v:VariantManagement>

<Controller>
//i can't get oVariantSave function
onAfterRendering: function () {
    var oVariantMgmtControl = this.getView().byId("vm");
}

//i can get oVariantSave function
onSelect: function (oEvent) {
    var oVariantMgmtControl = this.getView().byId("vm");
}

Please tell me how to get the oVariantSave function in onAfterRendering
and enable the "SAVE" button before the user takes action.

Thanks and Regards

taguchi
  • 1
  • 1

1 Answers1

0

If you want to enable SAVE button, you must set currentVariantSetModified to true. For example:

this.byId("variantManagment").currentVariantSetModified(true);

I hope that I am helpful :)

Dariusz
  • 1
  • 1
  • 1