Skip to Content
author's profile photo Former Member
Former Member

Controlling buttons (enable/disable) in sap.m.table based on another property


I am developing a master-detail SAPUI5 application that contains sap.m.table in details page with sap.m.button "Accept" for each row.

The requirement is this button should be enabled based on another property from ODATA response.

In the below code, i am creating a template with 3 columns as label & 4th column as button. This button should be enabled based on a property " Acceptance" that is returned from ODATA response. If the row is accepted, i should disable the button & if not, enable the button.

The problem is i will not have "Acceptance" property value till i do the binding. Looking into another forum, i found that there is a bindProperty() that gets called for each row & an object can be controlled through that. But, here also i am not able to get the Property value "Acceptance".

can anyone pls suggest how i can fetch the value of Acceptance & control this button enable/disable? I also tried calling a controller function from bindProperty, that also dint help.

pose_table.bindAggregation("items", {

path : "/ServiceEntrySheet",

template: new sap.m.ColumnListItem({

cells: [

new sap.m.Label({ text: "{SheetNo}" }),

new sap.m.Label({ text: "{GrossVal}" }),

new sap.m.Label({ text: "{Currency}" }),

new sap.m.Button("se_accept_btn",{

text : "Accept",

press : oController.approve,

visible : true,

//enabled : true,

}).bindProperty("enabled", "/ServiceEntrySheet",function(){

var sheetNumber = "{SheetNo}";


/*alert("accept button="+cellValue);


//alert("accepted ="+cellValue);




//alert("not accepted ="+cellValue);

enabled: true;







Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Aug 05, 2014 at 06:42 AM
    first off .setEnabled requires a boolean not a string; e.g .setEnabled( false ); you can get the property directly from the Model:
    property = sap.ui.getCore().getModel().getProperty( "/ServiceEntrySheet/Acceptance" ); //note: path might be different (i dont know exactly how your Odata response looks like)
    Also if you create more than one Item via this method doesn't new sap.m.Button("se_accept_btn"...) cause an issue since sapui only allows unique ids for objects? I could also suggest using a factory method for creating the items like: I personally always create items like this and this alway works for me

    code.PNG (31.2 kB)
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.