Skip to Content
avatar image
Former Member

Is it possible to edit text in sap.m.table in xml view?

is it possible to edit the text in table for the fileld like

<Text text="{company}"/>

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Oct 23, 2017 at 10:53 AM

    Hi Priya,

    You can use <Input> control. Set its property editable="true" to allow editing and false to display normal text.

    <Input type="Text" editable="true"></Input>
    
    Add comment
    10|10000 characters needed characters exceeded

    • Hi Priya,

      Either you can Disable or set Editable to false. As given below. If you want to Text field then use two fields in a table cell and play hide/visible with both by binding same property to them. You can do this in Change event of input field. As given below.

      <Input type="Text" editable="true" change="myFunction"></Input>
      
      myFunction : function(oEvent){
          oEvent.getSource().setEditable(false);
          oEvent.getSource().setEnabled(false);
      }
      
  • Oct 23, 2017 at 12:22 PM

    Hi Priya,

    Either you can Disable or set Editable to false. As given below. If you want to Text field then use two fields in a table cell and play hide/visible with both by binding same property to them. You can do this in Change event of input field. As given below.

    <Input type="Text" editable="true" change="myFunction"></Input>
    
    myFunction : function(oEvent){
        oEvent.getSource().setEditable(false);
        oEvent.getSource().setEnabled(false);
    }
    Add comment
    10|10000 characters needed characters exceeded

    • Hi Priya,

      Inside table cell put something like first sell with HorizontalLayout.

      <ColumnListItem vAlign="Middle">
      	<cells>
      	        <l:HorizontalLayout>
      			<Text text="{GTMdl>Class}" visible="{GTMdl>DisFldVis}"/>
      	           	<Input type="Text" visible="{GTMdl>CrtFldVis}"></Input>
      		</l:HorizontalLayout>
      		<Text text="{GTMdl>Class}" />
      	        <Text text="{GTMdl>Age}" />
      		<Text text="{GTMdl>Version}" />
      	</cells>
      </ColumnListItem>

      And your model data goes like this

      var oNVData = [{
      			//Other Fields
      			CrtFldVis : false, //flag for visibility of Create Fields
      			DisFldVis : true   //flag for visibility of Display Fields
      		},{
      			//Other Fields
      			CrtFldVis : false,
      			DisFldVis : true
      		},{
      			//Other Fields
      			CrtFldVis : false,
      			DisFldVis : true
      		}];
      var oJson = new sap.ui.model.json.JSONModel({"GTData":oNVData});
      this.getView().setModel(oJson, "GTMdl");

      Controller code on click of your text :

      VisCrtFld : function(oEvent) {
      		//this.getModel("GTMdl")
      //		debugger;
      		var sPath = oEvent.getSource().getBindingContext("GTMdl").getPath();
      		this.getView().getModel("GTMdl").setProperty(sPath+"/CrtFldVis", true);
      		this.getView().getModel("GTMdl").setProperty(sPath+"/DisFldVis", false);
      	}

      Tested and Working.

      If you have any doubts please ping me on my linkedIn

      Irfan Gokak

  • Oct 24, 2017 at 07:20 AM

    Hi Priya,

    You should use Input control for text editing. It has a property to make it non editable as well. - property name: editable and possible values are true or false.

    You can learn more about input control at below given link.

    https://sapui5.hana.ondemand.com/#/entity/sap.m.Input

    Add comment
    10|10000 characters needed characters exceeded