Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1145
Selecting the row by right clicking
posted

Hi 

I have added a context menu to a grid using the ui-context menu plugin as mentioned in this post.

I have used the following code in it's beforeOpen: handler to highlight the row

beforeOpen: function(event, ui) {
// find the row and select it to give user visual clue which row context menu is for
var rowIndex = $(ui.target).closest('tr').index();
$(gridElement).igGridSelection('selectRow', rowIndex);

},

However, this isnt always correct, if I expand a row (in a hierarchical grid) and right click below the expanded row, the indexing is off by 1. Right Clicking above teh expanded row still works. If I collapse the row, the issue remains.

So I am hoping that there is a more robust way of identifying the row that what I am currently using.

Regards

Aidan

Parents
No Data
Reply
  • 5513
    Verified Answer
    Offline posted

    Hello Aidan,

    You are right that the index is not stable in the case of a hierarchical grid. This can be avoided by excluding the hierarchical row containers which are marked with the data-container attribute. Your beforeOpen handler will then look like this:

    beforeOpen: function(event, ui) {
        // find the row and select it to give user visual clue which row context menu is fo
        var row = $(ui.target).closest("tr"),
            rowIndex = row.parent().children("tr:not([data-container='true'])").index(row);
        $(gridElement).igGridSelection('selectRow', rowIndex);
    },


    In the next SR for 2014.1 and for 2014.2 we'll be introducing API that selects rows by row ID and cells by row ID and column key. They should help solve issues coming from unstable indexes.

    I hope this helps! Thank you for using Infragistics forums!

    Best regards,

    Stamen Stoychev 


Children