cancel
Showing results for 
Search instead for 
Did you mean: 

List Sorting and Broken Navigation

former_member127929
Participant
0 Kudos

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

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member127929
Participant
0 Kudos

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

}

}

},

Former Member
0 Kudos

hi,

try using

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

If you are using multimodel binding use

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


Regards

former_member127929
Participant
0 Kudos

Hi Rajesh,

I end up with a "Uncaught TypeError: oItem.getSource is not a function"

Thanks,

Stuart

saivellanki
Active Contributor
0 Kudos

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.

former_member127929
Participant
0 Kudos

Hi Sai,

it gives me -


oItem.getBindingContext() - not available


Thanks,

Stuart