Skip to Content

Unable to update DetailPage list based on selection in MasterPage of SplitApp

manifest.txtproductslist.txtcategorieslist.txt

Hi,

I have developed a manifest based SplitApp application using the Northwind odata services wherein am displaying the categories on MasterPage & products on the DetailPage.

Upon click of a category, I retrieve the corresponding category ID, do an odata READ operation over products & then do a setModel for the products list on the DetailPage. However, my list always remains as empty. When I check in the console I can see that the product's model has successfully been updated but it doesn't reflect onto the list. I tried doing updateBindings(true), refresh(true) against the model but it didn't resolve the issue.

sap.ui.controller("uday.mypath.Controller.CategoriesList", {
	onCtgSel : function(oChosenCategory) {


		var iChosenCategory = oChosenCategory.getSource().mProperties.number;


		var sURL = "proxy/http/services.odata.org/OData/OData.svc";


		var sParams = "/Categories(" + iChosenCategory + ")/Products";


		var oModel = new sap.ui.model.odata.v2.ODataModel(sURL, {
			useBatch : false,
			maxDataServiceVersion : '3.0',
			defaultBindingMode : 'TwoWay'
		});


		oModel.read(sParams, {
			success : function(oData, response) {
				debugger;
				sap.ui.getCore().setModel(oData, "productsModel");
				oModel.updateBindings(true);
			},
			error : function(oData) {
				debugger;
			}
		})
	}


});

Alternatively, I wanted to see if I could directly access the list of my DetailPage but doing an sap.ui.getCore().byId() is returning back as undefined. Could someone please correct me as to where am going wrong.

Thanks

Add comment
10|10000 characters needed characters exceeded

  • Hi experts can anyone please pitch in advise over what might be the issue behind the List on the detailPage not getting updated with the data from the model? Haven't yet managed to resolve the issue.

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Oct 11, 2017 at 11:29 AM

    Hi Sekhar Mr,

    In the line sap.ui.getCore().setModel(oData,"productsModel"); oData is not a model, you should pass a JSON model here like below:

    var oJSONModel = new new sap.ui.model.json.JSONModel({Products: oData.results});
    sap.ui.getCore().setModel(oJSONModel,"productsModel");
    
    Add comment
    10|10000 characters needed characters exceeded

    • Hi Rahul,

      Thank you for the clarification. I shall try to explore & read more about this. Suppose in certain scenarios I only have the "this" keyword giving me a window reference, then how would I get the actual controllers reference? I was searching around and trying to understand how I can get the desired reference. Few threads spoke about saving aside the reference onto another variable for later use in the controller functions but am not sure that this is a proper approach. Any pointers would be greatly appreciated. Am a newbie at UI5.