Skip to Content
-1

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

May 22, 2017 at 07:06 AM

379

avatar image

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)
10 |10000 characters needed characters left characters exceeded

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

br,

seventyros

0

Hi seventyros roshan,

yes. i need to disable all update buttons.

0
* Please Login or Register to Answer, Follow or Comment.

4 Answers

VIPLOVE KHUSHALANI 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

Show 2 Share
10 |10000 characters needed characters left characters exceeded

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

0

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

0
Silent Monk May 22, 2017 at 10:57 AM
0

hi,

Please view below page for solution

Modify UI Control Properties via mAggregation

Thank you !

Silent Monk

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Sorry it was not working :(

0
Akhilesh Upadhyay May 24, 2017 at 08:45 AM
0

try this should work:

onAttachUpload: function(oEvent){
  var oButton = oEvent.getSource();
  oButton.setEnabled(false);
}
Show 1 Share
10 |10000 characters needed characters left 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.

0
Akhilesh Upadhyay May 24, 2017 at 10:12 AM
0

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);
}
Show 6 Share
10 |10000 characters needed characters left characters exceeded

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..?

0

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

0
0

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

0

Sorry i'll correct the mistakes. Thanks.

0

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

0