Skip to Content
0

How to make the cells of a sap.ui.table.Table editable ?

Jan 30, 2017 at 12:58 PM

43

avatar image

Hi experts,

I am developing a SAP UI5 application.

I need to make the second column of the table as editable , but not in all the rows.

For example : if table has 5 rows , then second and fourth row has to be editable.The column is fixed (second column but the row may vary depending upon the value from odata ) We have a field for Editable in ODATA and the value is set as either true or false.

Thanks,

Sandeep

var oPriceProcedureTable = new sap.ui.table.Table({
	id: "table-price",
	editable: false,
	selectionMode: sap.ui.table.SelectionMode.Single
});


oView.getModel().read("/PriceSet", {
	success: function(oData) {


		var priceData = oData.results;


		var Staic_Feilds = [{
			"Fieldname": "Material",
			"Edit": false,
			"ScrtextS": "Material Number"
		}, {
			"Fieldname": "Price",
			"Edit": true,
			"ScrtextS": "Unit Price"
		}, {
			"Fieldname": "UnitPrice",
			"Edit": false,
			"ScrtextS": "Unit"
		}, {
			"Fieldname": "PriceUnit",
			"Edit": false,
			"ScrtextS": "Price Unit"
		}, {
			"Fieldname": "TotalPrice",
			"Edit": false,
			"ScrtextS": "Total"
		}];


		var Column_name = Staic_Feilds;


		var oModel = new sap.ui.model.json.JSONModel();
		oModel.setData({
			columns: Column_name,
			rows: priceData
		});


		oPriceProcedureTable.setModel(oModel);


		oPriceProcedureTable.bindColumns("/columns", function(sId, oContext) {


			var columnName = oContext.getObject().Fieldname;
			var Editable = oContext.getObject().Edit;
			var ScrtextS = oContext.getObject().ScrtextS;


			return new sap.ui.table.Column({
				label: ScrtextS,
				template: new sap.ui.commons.TextField({
					value: {
						path: columnName
					},
					editable: Editable
				})
			});
		});
		oPriceProcedureTable.bindRows("/rows");


	},
	error: function() {
		sap.m.MessageToast.show("No data found");
	}
});

10 |10000 characters needed characters left characters exceeded

Hi ,

What is the current output you are getting for this code?

thanks

Viplove

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

0 Answers