/scripts/ahub.form.attachments.js
0

Get row from Table

Nov 11, 2016 at 10:27 AM

75

avatar image

Hi!

I want to get a row and put in Object Header.

It's my Object Header

	<ObjectHeader id="title" title=" {Kokrs} {Obart} {Layout} ( {Pjahr} / {Version} ) " introActive="false" titleActive="false" iconActive="false" backgroundDesign="Solid">
						<attributes>
							<ObjectAttribute active="false"/>
							<ObjectAttribute active="false"/>
						</attributes>
					</ObjectHeader>

I select a row in a table and would like to put this row in Object Header

Right now I get my data from table to this labels below Object Header by this way...But I have no idea how can I get object header from a table.

	var oSelectedItem = oEvent.getParameter("listItem") || oEvent.getSource().getSelectedItem().getBindingContext();
	
			
			var s1t = oSelectedItem.getBindingContext().getProperty("Status01Text");
			var oText = this.getView().byId("s1t");
			oText.setText(s1t);
			//Status01
			var s1 = oSelectedItem.getBindingContext().getProperty("Status01");
			var oText = this.getView().byId("s1");
			oText.setText(s1);


			var s1p = oSelectedItem.getBindingContext().getProperty("Status01Perc");
			var oText = this.getView().byId("s1p");
			oText.setText(s1p);
			//Status02		
			var s2t = oSelectedItem.getBindingContext().getProperty("Status02Text");
			var oText = this.getView().byId("s2t");
			oText.setText(s2t);


			var s2 = oSelectedItem.getBindingContext().getProperty("Status02");
			var oText = this.getView().byId("s2");
			oText.setText(s2);


			var s2p = oSelectedItem.getBindingContext().getProperty("Status02Perc");
			var oText = this.getView().byId("s2p");
			oText.setText(s2p);
			//Status03
			var s3t = oSelectedItem.getBindingContext().getProperty("Status03Text");
			var oText = this.getView().byId("s3t");
			oText.setText(s3t);


			var s3 = oSelectedItem.getBindingContext().getProperty("Status03");
			var oText = this.getView().byId("s3");
			oText.setText(s3);


			var s3p = oSelectedItem.getBindingContext().getProperty("Status03Perc");
			var oText = this.getView().byId("s3p");
			oText.setText(s3p);


			//status04


			var s4t = oSelectedItem.getBindingContext().getProperty("Status04Text");
			var oText = this.getView().byId("s4t");
			oText.setText(s4t);


			var s4 = oSelectedItem.getBindingContext().getProperty("Status04");
			var oText = this.getView().byId("s4");
			oText.setText(s4);


			var s4p = oSelectedItem.getBindingContext().getProperty("Status04Perc");
			var oText = this.getView().byId("s4p");
			oText.setText(s4p);


			//Status05


			var s5t = oSelectedItem.getBindingContext().getProperty("Status05Text");
			var oText = this.getView().byId("s5t");
			oText.setText(s5t);


			var s5 = oSelectedItem.getBindingContext().getProperty("Status05");
			var oText = this.getView().byId("s5");
			oText.setText(s5);


			var s5p = oSelectedItem.getBindingContext().getProperty("Status05Perc");
			var oText = this.getView().byId("s5p");
			oText.setText(s5p);


			//Status 06


			var s6t = oSelectedItem.getBindingContext().getProperty("Status06Text");
			var oText = this.getView().byId("s6t");
			oText.setText(s6t);


			var s6 = oSelectedItem.getBindingContext().getProperty("Status06");
			var oText = this.getView().byId("s6");
			oText.setText(s6);


			var s6p = oSelectedItem.getBindingContext().getProperty("Status06Perc");
			var oText = this.getView().byId("s6p");
			oText.setText(s6p);
3.png (87.0 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

VIPLOVE KHUSHALANI Nov 11, 2016 at 12:17 PM
0

Hi Khristina,

i don't understand your exact requirement , but i think you are asking how to get the data from the selected record of the table and attach to the object header (assuming object header is in the same view as of table). For sap.m.table there is a event selectionChange (call onRecordSelection function handler) you need to use that to get the selected data record

controller :

onRecordSelection:function(oEvent){

var data = oEvent.getParameter("listItem").getBindingContext(<modelName if mentioned while attaching model to table>).getProperty();

// data contains all the row fields of the selected row , after getting attach it to the object header

var model = new sap.ui.model.json.JSONModel();// creating json model

model.setData({selectedSet:data});//attaching selected row data to the model

this.getView().byId("<id of object header>").setModel(model);//attach model to the control(object header in your case)

this.getView().byId("<id of object header>").bindElement("/selectedSet");// binding object to the control

},

Note: In above case tableitems attached fieldsNames and object header propertyNames needs to be same

i hope this helps , let me know if you face any issues after this too .

thanks

Viplove

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thank you very much!!!! It works:)

1
Skip to Content