cancel
Showing results for 
Search instead for 
Did you mean: 

Populating a column of a grid table containing a ComoBox

0 Kudos

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:"{}"			 
		 })	 
	 }));
		
	 



Accepted Solutions (1)

Accepted Solutions (1)

former_member340030
Contributor
0 Kudos

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

0 Kudos

Hi viplove,

Thanks for your help.

The code is working now.

Regards

Aman

Answers (1)

Answers (1)

0 Kudos

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

former_member340030
Contributor
0 Kudos

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