on 02-28-2018 8:46 AM
Hi,
I am trying to pass the values of selected items from multiComboBox to another view to bind it in a table. I am getting the selected values as
view1.controller.js code:
var selectedItems = [];
selectedItems = oEvent.getParameter("selectedItems");
oRouter.navTo("page2", {
value : JSON.stringify(selectedItems)
}
manifest.json code:
{
"pattern": "page2/{value}",
"name": "page2",
"target": "page2"
}
view2.controller.js code:
var output = JSON.parse(oEvent.getParameters("arguments").value);
alert(output);
I am getting the error as
Uncaught TypeError: Converting circular structure to JSON
Can any one help me with this?
Thanks,
Janani
just put it in model, no need to pass through url
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
It will be helpful if you refer me some blogs related to this.
Thanks,
Janani
Since selected items is an array of objects with circular reference, i don't think you can stringify it:
Is not an array with key and text enough?
var selectedItems = oEvt.getParameter("selectedItems");
var selectedKeys = [];
for (var i=0; i<selectedItems.length; i++) {
selectedKeys.push({key: selectedItems[i].getProperty("key"), "text": selectedItems[i].getProperty("text")});
}
console.log(JSON.stringify(selectedKeys));
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Francesco,
With console.log(JSON.stringify(selectedKeys));
I am getting key value pair of the selected items as array of objects. I need to pass this object values to another view to bind it in a table. While passing it in the route section as
oRouter.navTo("page2", {
value:JSON.stringify(selectedKeys)
}
I am getting error as Uncaught SyntaxError: Unexpected token u in JSON at position 0
Thanks,
Janani
Hi Janani, can you also print the content of the JSON?
I think you have two options:
1) base64 of the value (so you don't have JSON in your url) and decode it on the onRouteMatched
2) If you don't mind losing the deep link to that page you can still save those values inside a temp JSON model and retrieve it on the onRouteMatched event 😉
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
11 | |
10 | |
8 | |
6 | |
6 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.