Skip to Content
-1

How to disable the button inside Customlistitem while press the View Button

Hi All,

I want to disable the update button in the CustomListItem while press the Upload Button in the view. I tried the disable option but it works only for the first array. Pls suggest some idea.

Attached Image and tried code.

Code View:

<Button id ="attach" text="Upload" type="Emphasized" press="onAttachUpload" > </Button>

Controller:

onAttachUpload:function(){

this.getView().byId("updatedis").setEnabled(false);

},

disable-button.png (16.8 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • May 23, 2017 at 07:11 AM
    -1

    Hi,

    You need to use model for this as you cannot directly get control using the Id of the control and apply setEnabled false. As the Id is not same for all the buttons in the custom list item.

    Code in view :

    // update button

    <Button enable="{emodel>evalue}" > </Button>

    Code in controller

    onInit :function()

    {

    var enable = {evalue:true};

    var emodel = new sap.ui.model.json.JSONModel();

    emodel.setData(enable);

    this.getView().byId("<tableId>").setModel(emodel,"emodel");

    this.getView().byId("<tableId>").bindElement("emodel>/");

    }

    onAttachUpload:function(){

    var enable = this.getView().byId("<tableId>").getBindingContext("emodel").getProperty();

    enable.evalue = false;

    var emodel = new sap.ui.model.json.JSONModel();

    emodel.setData(enable);

    this.getView().byId("<tableId>").setModel(emodel,"emodel");

    this.getView().byId("<tableId>").bindElement("emodel>/");

    }

    this will disable all the update buttons

    thanks

    Viplove

    Add comment
    10|10000 characters needed characters exceeded

    • Hi ,

      <tableId> is your table's id you need to place here id of your table don't just directly copy paste the code bro , did you mention any id to your table if not than mention it and than use it ... undefined of getBindingContext means you don't of any control in your view of the mentioned id .

      thanks

      Viplove

  • avatar image
    Former Member
    May 22, 2017 at 10:57 AM

    hi,

    Please view below page for solution

    Modify UI Control Properties via mAggregation

    Thank you !

    Silent Monk

    Add comment
    10|10000 characters needed characters exceeded

  • May 24, 2017 at 08:45 AM

    try this should work:

    onAttachUpload: function(oEvent){
      var oButton = oEvent.getSource();
      oButton.setEnabled(false);
    }
    Add comment
    10|10000 characters needed characters exceeded

    • Thanks for the reply.

      The code you shared will disable the particular button. But, I want to disable the (upload) button which is inside the list. while press the (update) Button.

  • May 24, 2017 at 10:12 AM

    ah..i took it another way i guess, basically approach should be :

    // update button
    <Button enabled="{viewModel>/bEnableUpdate}"></Button>
    //Code in controller
    onInit: function() {
        var viewProperties = {
            bEnableUpdate: true
        };
        var viewModel = new sap.ui.model.json.JSONModel(viewProperties);
        this.getView().setModel(viewModel, "viewModel");
    },
    onAttachUpload: function() {
        this.getView().getModel("viewModel").setProperty("/bEnableUpdate", false);
    }
    Add comment
    10|10000 characters needed characters exceeded