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
411
Error with CSOM MouseDown
posted

I have found that when trying get the item on a mousedown event, from the eventargs variable, will return null for any child bands.

Is this an error or something I need to catch in my javascript?

Parents
No Data
Reply
  • 411
    Suggested Answer
    posted

    It seems I keep finding answers to my questions myself!

    Here is the code I came up with in JS to find the selected child row:

    function FindSelectedRow(grid_to_check) {

                lastSelectedRow = null;

                for (i = 0; i < grid_to_check.get_rows().get_length(); i++) {

                    if (grid_to_check.get_behaviors().get_selection().get_selectedRows().get_length() > 0) {

                        if (grid_to_check.get_behaviors().get_selection().get_selectedRows().indexOf(grid_to_check.get_rows().get_row(i))>=0) {

                            lastSelectedRow = grid_to_check.get_rows().get_row(i);

                            break;

                        }

                    }

                    if (lastSelectedRow == null) {

                        if(grid_to_check.get_rows().get_row(i).get_isEmptyParent())

                            FindSelectedRow(grid_to_check.get_rows().get_row(i).get_rowIslands(0)[0]);

                    }

                }

            }

     

    and in the mouse down event

     

    if (eventArgs.get_item() == null || !eventArgs.get_item().get_row || eventArgs.get_item().get_row().get_index() == -1) {

                    for (i = 0; i <= grid.get_rows().get_length() - 1; i++) {

                        FindSelectedRow(grid.get_rows().get_row(i).get_rowIslands(0)[0]);

                    }             

                }

                else {

                    lastSelectedRow = eventArgs.get_item().get_row();

                }

Children
No Data