on 2021 Sep 10 3:01 AM
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
Request clarification before answering.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No problem, another couple of ideas for you.
Combine your query and json conversion into a single transaction and just call the transaction. Or you could use a javascript library in your irpt such as XML2JSON. Or since you are using UI5 you could use an XML model rather than a JSON model - check this Blog.
Thanks
Kevin
Thanks Kevin, that gave me the final piece for the puzzle - setting path for the select binding to '/Rowsets/Rowset/0/Row' instead of '/options',
so my JSON instantiation became:
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");
and I add it to the Select object with:
oSelect.setModel(my_Model);
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.