Skip to Content
0

Items not stored in multiComboBox after refresh

Feb 23, 2017 at 04:49 AM

33

avatar image
Former Member
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)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Srikanth KV Feb 23, 2017 at 05:17 PM
0

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.

Share
10 |10000 characters needed characters left characters exceeded