cancel
Showing results for 
Search instead for 
Did you mean: 

Disable row in SAP UI5 table

aswani_sanjay
Explorer

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

karthikarjun
Active Contributor
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

former_member227918
Active Contributor
0 Kudos

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

Answers (1)

Answers (1)

karthikarjun
Active Contributor
0 Kudos

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