Skip to Content

How to pass array values(from multiComboBox) in routing

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Feb 28 at 02:10 PM

    just put it in model, no need to pass through url

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 28 at 09:48 AM

    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));
    
    Add comment
    10|10000 characters needed characters exceeded

  • Feb 28 at 09:21 AM

    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 ;)

    Add comment
    10|10000 characters needed characters exceeded