Skip to Content
avatar image
Former Member

Disable row in SAP UI5 table

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Oct 19, 2016 at 06:08 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 19, 2016 at 05:58 AM

    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;
      }
     
      
      })
    }));
    
    Add comment
    10|10000 characters needed characters exceeded