Skip to Content
0

Populating a column of a grid table containing a ComoBox

Apr 21, 2017 at 06:07 AM

58

avatar image

Hi Experts,

I have a grid table in which one column is a combobox . I want to populate the combobox

with the entries using oData . I want to know how to do that. I am posting my code for the grid table below. 
		var tblContractLineDescription = new sap.ui.table.Table("tbl_ContractLineDescription",{			
			selectionMode :sap.ui.table.SelectionMode.MultiToggle,
			selectionBehavior:sap.ui.table.SelectionBehavior.RowSelector,
			title : "Contract Line Description"
		});			
		tblContractLineDescription.addColumn(new sap.ui.table.Column({
			label : new sap.m.Label({text : "Contract Line Description"}),
			template : new sap.m.Text({text : "{OrderID}"}),
			}));	 
	 tblContractLineDescription.addColumn(new sap.ui.table.Column({
			label : new sap.m.Label({text : "Unit Of Measure"}),
			
			template : new sap.m.Text({text : "{}"
				,editable:true})					 
			}));
	 tblContractLineDescription.addColumn(new sap.ui.table.Column({
		 label:new sap.m.Label({
			 text:"Commodity Code"}),
		 template:new sap.m.Text({	
			 text:"{}"			 
		 })	 
	 }));	
	 tblContractLineDescription.addColumn(new sap.ui.table.Column({
		 label:new sap.m.Label({
			 text:"Count"
		 }),
		 template:new sap.m.Input({	
			 text:"{}"			 
		 })	 
	 }));	



	
	 tblContractLineDescription.addColumn(new sap.ui.table.Column({
		 label:new sap.m.Label({
			 text:"Sub Commodity Code"
		 }),
	
		 
		 template: new sap.m.ComboBox("cbx_forTable",{
			 
			 
			 text:"{EmployeeID}"
			 		 
		 })
	 
	 }));
	 
	 tblContractLineDescription.addColumn(new sap.ui.table.Column({
		 label:new sap.m.Label({
			 text:"Comment"
		 }),
		 template:new sap.m.Input({	
			 text:"{}"			 
		 })	 
	 }));
		
	 



10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
VIPLOVE KHUSHALANI Apr 21, 2017 at 07:41 AM
0

Hi Aman ,

You can do like this :

var cTemplate = new sap.ui.core.ListItem();

cTemplate.bindProperty("key","<key variable in the comboBox data>");

cTemplate.bindProperty("text","<text variable in the comboBox data>");

template : new sap.m.ComboBox().bindItems("<path of the comboBox data>",cTemplate).bindProperty("selectedKey","<key of initial selected Item>");

thanks

viplove

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

Hi viplove,

Thanks for your help.

The code is working now.

Regards

Aman

0
Aman Anand Apr 24, 2017 at 05:06 AM
0

Hi viplove,

I have to insert this as a column inside a grid table. I tried your solution but its not giving the result .

Thanks

Aman

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

Sorry, i think might be i mentioned the wrong item of the combo template ..

replace var cTemplate = new sap.ui.core.ListItem(); with var cTemplate = new sap.ui.core.Item();

If that doesn't work too than can you just share you code . i can take a look and get back to you after seeing it

thanks

Viplove

0