Skip to Content
0

Disable row in SAP UI5 table

Oct 18, 2016 at 08:57 PM

389

avatar image

Hi Experts,

I am using sap.ui.table.table control in my application.

I have an requirement to disable rows depending upon some flag lets say XRow.

I know we can't disable a row but we can set the editable property for controls in column as false/true using the formatter with XRow.

But my issue I also has individual flags for these columns. So I don't know how to apply two formatters for a single column (One with XRow and another with individual flag)

Could you please help.

Thanks

Sanjay

10 |10000 characters needed characters left characters exceeded

Hi Sanjay- Do you have edit option in table? ex: Input field, radio button, checkbox

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

2 Answers

Best Answer
Akhilesh Upadhyay Oct 19, 2016 at 06:08 AM
0

Hello,

I think you can pass multiple values in a parts, try this,

Binding in XML:
<Input editable="{parts:['XRow', 'indivedual flag'], formatter: '.setRowEditable'}" />

JS:
setRowEditable: function(bRowFlag, bIndividualFlag) {
    var bEditable = false;
    if (!bRowFlag) {
        bEditable = false;// i think, if XRow is false then individual flag should not be considered
    } else {
        bEditable = bIndividualFlag;
    }
    return bEditable;
}

Hope this what you looking for.

Regards,

Akhilesh

Share
10 |10000 characters needed characters left characters exceeded
A K Oct 19, 2016 at 05:58 AM
0

USE THIS CODE:

//Define some sample data
var aData = [
	{ flag :"YES", rating: 3},
	{ flag :"NO", rating: 3}
];


//Create an instance of the table control
var oTable = new sap.ui.table.Table({
	title: "Table Example",
	selectionMode: sap.ui.table.SelectionMode.Single
});


oTable.addColumn(new sap.ui.table.Column({
	label: new sap.ui.commons.Label({text: "Checked"}),
	template: new sap.ui.commons.CheckBox().bindProperty("checked","flag",function(data){
  this.false = false;
  if(data === "YES"){
  this.setProperty("editable",this.false);
  return !this.false;
  }
 
  
  })
}));






//Create a model and bind the table rows to this model
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData({modelData: aData});
oTable.setModel(oModel);
oTable.bindRows("/modelData");


//Bring the table onto the UI
oTable.placeAt("content");


	


	
,

Hi Sanjay- I hope this code will helpful to you. Please find below link.

https://fiddle.jshell.net/KarthikArjun/xaptfysL/1/

oTable.addColumn(new sap.ui.table.Column({
	label: new sap.ui.commons.Label({text: "Checked"}),
	template: new sap.ui.commons.CheckBox().bindProperty("checked","flag",function(data){
  this.false = false;
  if(data === "YES"){
  this.setProperty("editable",this.false);
  return !this.false;
  }
 
  
  })
}));
Share
10 |10000 characters needed characters left characters exceeded