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
960
How can i use ui.grid in an event?
posted

If I set up a function to call when a RowSelector is clicked, how do I use the ui.grid to get the selected row? From your help :

    $(document).delegate(".selector", "iggridrowselectorsrowselectorclicked", function (evt, ui) {
        // get reference to the igGrid the igRowSelectors are initialized for
        ui.grid;
    });
But when I try to USE ui.grid it fails :

var row = $(ui.grid).igGridSelection('selectedRow');

var row = ui.grid.igGridSelection('selectedRow');

So how do I access the selected row or rows (if multiple selection is enabled)

Thank you


  • 17590
    Offline posted

    Hello C J,

    Thank you for posting in our community.

    In order to get reference to the igGrid from the rowSelectorClickedEvent what I can suggest is using ui,grid.element. This could be achieved as following:

    $(document).delegate("#cbRowSelectors", "iggridrowselectorsrowselectorclicked", function (evt, ui) {
            var row = $(ui.grid.element).igGridSelection('selectedRow');
        //if multiple selection is enabled the selectedRows method should be used to return the collection of selected rows
        alert("Selected row index is :" + row.index);
                });

    In case that you have multiple selection enabled the selectedRows method should be used to return the collection of selected rows.

    I am also attaching a small sample demonstrating my suggestion for your reference.

    I hope you find this information helpful.

    Please let me know if you need any further assistance with this matter.

    igGridRowSelectorsEvent.zip