Question

I have a table with a filter. If I use this code to select the row that I clicked before add a filter it retrieve incorrect index:

handleRowPress : function(evt){

        var selectedRowNum = evt.getSource().indexOfItem(evt.getParameter("listItem"));
        ...

    },

For example if I have 5 results A B C D E and after filter I have C and E, whith previous code if I click on E, selectedRowNum is 2, but I want 5!

Was it helpful?

Solution

You can get the binding context path of your selected list item and then get the index of the row.

var itemContextPath = evt.getParameter("listItem").getBindingContextPath();

var indexOfRow = parseInt(itemContextPath.substring(itemContextPath.lastIndexOf("/")+1, itemContextPath.length));

Regards, Allen

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top