Question

I am trying to retrieve the line number in dojo data grid. rowIndex function would not help me much because I need the 'line number' and NOT 'row number' when sorted.

The scenario:

I would like to set the focus on one specific row and this focus should remain even after sorting. But if I use the code below, it does not select the correct row.

For example, the index 1 is on the 5th line after sorting. However, the e.item.id still remains as 1, expected is 5.

calendar.on("itemClick", function (e) 
{ 
    MyGrid.doclick({ rowIndex: e.item.id }); 
    MyGrid.scrollToRow(e.item.id); 
});

Additionally, I also tried...

calendar.on("itemClick", function (e)
{
    var identity = MyGrid._by_idx[e.item.id].idty;

    var gridItem = MyGrid.getItem(identity);
    var gridItemIndex = MyGrid.getItemIndex(gridItem);

    MyGrid.doclick({ rowIndex: gridItemIndex });
    MyGrid.scrollToRow(e.item.id);
});

Could you please let me know how to get the correct row after fitering? I thank you for your time.

Wishes, Santosh

Was it helpful?

Solution

Okay, I figured out the answer.

GetGridItemIndexByGridItem = function (gridItem) { 
    var indexLength = MyGrid._by_idx.length; 
    var element = null; 
    var gridItemIndex = -1; 

    for (var i = 0; i < indexLength; i++) { 
        element = MyGrid._by_idx[i]; 
        if (element.item.Guid == gridItem.Guid) { 
            gridItemIndex = i; 
        } 
    } 
    return gridItemIndex; 
}

Best Wishes

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