cancel
Showing results for 
Search instead for 
Did you mean: 

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

former_member187227
Participant

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);

},

former_member187977
Participant
0 Kudos

Do you want to disable all 'update' buttons on the event of upload ?

br,

seventyros

former_member187227
Participant
0 Kudos

Hi seventyros roshan,

yes. i need to disable all update buttons.

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member227918
Active Contributor

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);
}
former_member187227
Participant
0 Kudos

Hi Akhilesh Upadhyay,

Thanks for the reply. I have tried your code. Initially all the buttons are visible.But when I try to disable all the buttons next time,

only the first button is getting disabled.

Can u help me with this..?

former_member227918
Active Contributor
0 Kudos

you are doing something wrong, it should work!, how you are trying ? share your code

former_member187227
Participant
0 Kudos
former_member227918
Active Contributor
0 Kudos

simply you are not able to copy paste above code and understand the meanings of lines ?

and also naming conventions you have used its very bad.

anyways, please change below line and see the working effect.

do not use : var rr = this.getView().byId("btn");

use : var rr = this.getView();

former_member187227
Participant
0 Kudos

Sorry i'll correct the mistakes. Thanks.

former_member227918
Active Contributor
0 Kudos

please accept above thread if resolved your issue, it will help to others for same issue.

NicholasB
Product and Topic Expert
Product and Topic Expert
0 Kudos

Nice hint! I needed it in another scenario though (show button if line selected). I just set my button to false onInit (like done in onAttachUpload) and to true once I select a table line.

former_member227918
Active Contributor

try this should work:

onAttachUpload: function(oEvent){
  var oButton = oEvent.getSource();
  oButton.setEnabled(false);
}
former_member187227
Participant
0 Kudos

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.

former_member340030
Contributor

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

former_member187227
Participant
0 Kudos

Sorry its not working. Getting error as undefined of getBindingContext.

former_member340030
Contributor
0 Kudos

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

former_member187977
Participant
0 Kudos

hi,

Please view below page for solution

Modify UI Control Properties via mAggregation

Thank you !

Silent Monk

former_member187227
Participant
0 Kudos

Sorry it was not working 😞