Skip to Content
avatar image
Former Member

Items not stored in multiComboBox after refresh

Hi,
Below is the code. In this code I have declared a variable name 
"roStremItems" in which I am getting the items which is in MultiComboBox
control, Problem is that when I navigate to this page, I can get all the 
items by using getItems() function from MultiComboBox control. But when I 
refresh this page it is not giving me the items.

Please see the screenshots afternavigation.jpg and afterrefresh.jpg for reference

var unitContextPath =evt.getParameter("arguments").unitContextPath;
var viewModel=this.getView().getModel();
viewModel.read("/"+unitContextPath, //Getting the data which under "/unitContextPath"
  {
    success:
      function(oData,oResponse)
         {
           oModel = new sap.ui.model.json.JSONModel();
           oModel.setData(oData); //Set Data from viewModel declare above
           sap.ui.getCore().byId("unitForm").setModel(oModel,"unit"); //Apply Data to "unitForm"
           getUnitCode=sap.ui.getCore().byId("unitCode_Input").getValue();
//Get "unitCode_Input" value this control is in view under simple form
control
           var filters =[];
           var aFilter;
           aFilter= new sap.ui.model.Filter("unit_code.unit_code",sap.ui.model.FilterOperator.EQ,getUnitCode);
filters.push(aFilter);
sap.ui.getCore().byId("unitBoxes_Input").getBinding("items").filter(filters);//Bind Items to "unitBoxes_Input" multiComboBox control

var roStreamItems=sap.ui.getCore().byId("unitBoxes_Input").getItems();
//Get Items which are bind in prev line. The issue is in this line on refresh this linke is not give the items.
sap.ui.getCore().byId("unitRo_Input").setSelectedItems(roStreamItems);
//Select the items which are binded
} ,
error:
function()
  {
    console.log("error retrieving the value of unit"); //Error will come if the service not found
}
Please Suggest.
Thanks in Advance
Somdutt
afternavigation.jpg (116.5 kB)
afterrefresh.jpg (97.1 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Feb 23, 2017 at 05:17 PM

    There is no persistent data storage in your application. Are you storing the selected checkboxes into a DB? if so then the same can be retrieved after page refresh as part of 'init' method of controller and loaded into the UI.

    When you are navigating within the app, all the data is stored as part of JSON model and can be accessed. When you refresh the page JSON model is created again newly.

    Add comment
    10|10000 characters needed characters exceeded