Skip to Content

How can I get JSON as function Parameter in sapui5 m.table?

I have tried to create dynamic combobox or multiInput in dynamic table. You can see below my the view screen that I expect and my own code.

onCreateTable: function () {
			var summaryDetailData = {
				"subvariants": [{
					"kontrolNesnesiTanim": "test 1 Tanım",
					"kontrolNesnesiBelirtim": "test 1 Belirtim",
					"type": "comboBox",
					"kontrolSonucu": {
						"test0": "test00",
						"test1": "test10",
						"test2": "test20"
					},
					"kontrolEdilecek": 20,
					"kontrolEdilen": 0,
					"icon": "sap-icon://accept"
				}, {
					"kontrolNesnesiTanim": "test 2 Tanım",
					"kontrolNesnesiBelirtim": "test 2 Belirtim",
					"type": "input",
					"kontrolSonucu": {
						"test0": "test00",
						"test1": "test10",
						"test2": "test20",
						"test3": "test30"
					},
					"kontrolEdilecek": 10,
					"kontrolEdilen": 0,
					"icon": "sap-icon://decline"
				} ]
			};


			var oTable = new sap.m.Table("idRandomDataTable", {
				headerToolbar: new sap.m.Toolbar({
					content: [new sap.m.Label({
						text: ""
					})]
				}),
				columns: [new sap.m.Column({
					width: "2em",
					header: new sap.m.Label({
						text: "Kontrol Nesnesi"
					})
				}), new sap.m.Column({
					width: "2em",
					header: new sap.m.Label({
						text: "Kontrol Sonucu"
					})
				}), new sap.m.Column({
					width: "2em",
					header: new sap.m.Label({
						text: "Kontrol Edilecek"
					})
				})]
			});
			this.getView().byId("SimpleFormChange480_TrialSonuc").addContent(oTable);
			oTable.bindItems("/subvariants", new sap.m.ColumnListItem({
				cells: [new sap.m.ObjectIdentifier({
						title: "{kontrolNesnesiTanim}",
						"titleActive": true,
						text: "{kontrolNesnesiBelirtim}"
					 }),
					 this.kontrolSonucu("{type}"), 
					 new sap.m.Input({
						value: "{kontrolEdilen}"
					})
				]
			}));


			oTable.setModel(new sap.ui.model.json.JSONModel(summaryDetailData));
		},


		kontrolSonucu: function (type) {
			if (type === "input") {
				return new sap.m.MultiInput({
					showValueHelp: false
				});
			} else {
				return new sap.m.ComboBox({
					items: {
						path: "kontrolSonucu/",
						template: new sap.ui.core.Item({
							key: "{}",
							change: "onChange",
							text: "{}"
						})
					}
				});
			}
		}
<br>

How can I get JSON as function Parameter?

And also I want to use sap.m.table library not sap.ui.table

I am looking forward your response.

Thanks

stackquest.png (11.5 kB)
Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

0 Answers