cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to fill a JSON model from an MII Query Template

alan_myers
Explorer
0 Likes
990

Hi,

I have a UI% select dropdown that I populate from a static JSON model. Can anyone point me to some documentation on how to change this to populate the JSON model from an MII Query Template please? I have spent days looking at forum sites and experimenting, but have not even come close to getting it to work.

My JSON code looks like this:

oSelect.setModel(new JSONModel({
selectedKey: "A2",
options: [{
key: "A1", text: "Peter" }, {
key: "A2", text: "Gill"}, {
key: "B1", text: "Harry"}, {
key: "B2", text: "Ralph"}, {
key: "C1", text: "Jack"}, {
key: "C2", text: "Jill"}, {
key: "D1", text: "Harry"}, {
key: "D2", text: "Sally"}
]
}));

Cheers, Alan

View Entire Topic
alan_myers
Explorer
0 Likes

In case anyone stray across this question, here is my working solution, thanks to the guidance from Kevin and some other blogs.

.....

var my_Model = new sap.ui.model.json.JSONModel();
var my_URL = "/XMII/Illuminator?QueryTemplate=qryTemplateName&Content-Type=text/json&Param.1="+varParam1;
my_Model.loadData(my_URL, '', false, "POST");

.........

sap.ui.define(['sap/m/Select', 'sap/ui/core/Item', 'sap/ui/model/json/JSONModel'],
function (Select, Item, JSONModel) {
var oSelect = new Select({
selectedKey: 'keyvalue1',
items: {
path: '/Rowsets/Rowset/0/Row',
template: new Item({
key: '{keyFieldName}',
text: '{testFieldName}'
}),
},
change: function (oEvent) {
var selectedItem = oEvent.getParameter("selectedItem");
if (selectedItem) {
Selected_Text = selectedItem.getText();
Selected_Key = selectedItem.getKey();
alert(Selected_Key+'-'+Selected_Text);
}
}
});

oSelect.setModel(my_Model);
oSelect.placeAt('div1');

});