Skip to Content

List Sorting and Broken Navigation

Hi All,

I have a xml split view app that works correctly. However when I add Sorting to the Master List XML I start to see the error "Uncaught TypeError: Cannot read property 'getPath' of undefined"

The sorting was added like this, and it displays correctly when I run the app,

items="{

  path : '/Carriers',

  sorter : {

  path : 'Category',

  group : true

  }

The error in the code appears here:

showDetail: function(oItem) {

// If we're on a phone device, include nav in history

var bReplace = jQuery.device.is.phone ? false : true;

this.getRouter().navTo("detail", {

from: "master",

entity: oItem.getBindingContext().getPath().substr(1),

tab: this.sTab

}, bReplace);

},

Thanks,

Stuart

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Oct 15, 2015 at 08:28 AM

    Hi Stuart,

    Can you run the program in debugging mode and place a break point on showDetail function. When it hits the break point, type this in console and check what you're getting for oItem.getBindingContext().getPath()

    check oItem.getBindingContext() as well.

    Regards,

    Sai Vellanki.

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 15, 2015 at 08:43 AM

    hi,

    try using

    oItem.getSource().getBindingContext().getPath().

    If you are using multimodel binding use

    oItem.getSource().getBindingContext("<modelname>").getPath().


    Regards

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 15, 2015 at 01:44 PM

    So it looks like adding Sorting was triggering the 'Select' event somehow, and the Grouping was adding items to my list array.

    I changed the onSelect function as follows and now it seems to work:

    onSelect: function(oEvent) {

    // Get the list item either from the listItem parameter or from the event's

    // source itself (will depend on the device-dependent mode)

    //this.showDetail(oEvent.getParameter("listItem") || oEvent.getSource());

    //this.showDetail( oEvent.getSource());

    if (!sap.ui.Device.system.phone) {

    var oList = this.getView().byId("list");

    var aItems = oList.getItems();

    if (aItems.length && !oList.getSelectedItem()) {

    oList.setSelectedItem(aItems[1], true);

    this.showDetail(aItems[1]);

    } else {

    this.showDetail(oList.getSelectedItem());

    }

    }

    },

    Add comment
    10|10000 characters needed characters exceeded