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
65
Multi row selection without using CTRL/SHIFT
posted

Is it possible to select multiple rows in a WebDataGrid without holding CTRL, SHIFT, or dragging?  Basically, I would like the selected rows to remain "sticky", kind of like a checkbox functionality, except with the row selection element (ie. click an unselect row to select, click a selected row to unselect - but without affecting the rest of the selected rows in the process).

I've tried tricking the event object in the browser into thinking the CTRL key is pressed (via JS), but I don't think it's possible.

Parents
No Data
Reply
  • 33839
    Suggested Answer
    posted

    Hi Koojo,

    This should be possible with a little code on the client.  You will want to turn on selection behavior, but set CellSelectType="None" and RowSelectType="None".  This will mean the actual behavior will do no selecting from the UI.  Now, you will want to handle the grid's click or mouse down event.  In that handler, you will select the clicked row if it is unselected or unselect it if it were already selected.

    function wdg_Click(webDataGrid, evntArgs)
            {
                var ControlClicked = evntArgs.get_type();
                var row = null;
                var selectedRows = webDataGrid.get_behaviors().get_selection().get_selectedRows();
                if (ControlClicked == 'row')
                {
                    row = evntArgs.get_item();
                    webDataGrid.get_behaviors().get_selection().get_selectedRows().clear();
                }
                else if (ControlClicked == 'cell')
                {
                    row = evntArgs.get_item().get_row();
                }
                if (row != null)
                {
                    if (selectedRows.indexOf(row) > -1)
                        webDataGrid.get_behaviors().get_selection().get_selectedRows().remove(row);
                    else
                        webDataGrid.get_behaviors().get_selection().get_selectedRows().add(row);
                }
            }

    I hope this gives you the behavior that you want.

    regards,

    David Young

Children