Skip to Content
0
Former Member
Aug 05, 2014 at 05:48 AM

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

4189 Views

Hi,

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

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

if("{Acceptance}"=="X"){

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

this.setEnabled("false");

this.setText("Accepted");

}else{

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

enabled: true;

}*/

}),

]

})

});

Dharini.,