ui-grid icon indicating copy to clipboard operation
ui-grid copied to clipboard

enableFullRowSelection turns off enableRowHeaderSelection?

Open dereklin opened this issue 10 years ago • 4 comments

According to the documentation, http://ui-grid.info/docs/#/tutorial/210_selection

"f you want to allow both clicking on the row, and also clicking on the rowHeader, you can set enableFullRowSelection to true."

I tried to do that: http://plnkr.co/edit/W8G2Bpp64msV9sCvYFSc?p=preview

But I can only select the row by the row body, not the header.

How can I enable selection by both the row body and header?

dereklin avatar Jun 15 '16 21:06 dereklin

It appears that class ui-grid-disable-selection is being set to all .ui-grid-cell. That class applies the following CSS property to row headers specifically, but not to non-header cells:

.ui-grid-cell.ui-grid-disable-selection.ui-grid-row-header-cell {
    pointer-events: none;
}

Setting pointer-events: none; prevents the click handler from firing when clicking the row header, thus the rows selected state does not toggle. This class is applied from the function registerRowSelectionEvents().

Reading the documentation, it seems that only enableFullRowSelection should be used for your desired result. enableRowSelection enables row selection for the entire grid. enableFullRowSelection enables the entire row to be clicked for row selection. enableRowHeaderSelection is true by default and simply toggles the visibility of the selection headers.

That being said, enableFullRowSelection does not work as expected because of pointer-events: none;.

A workaround would be to override the css with your own:

.ui-grid-cell.ui-grid-disable-selection.ui-grid-row-header-cell {
    pointer-events: auto;
}

Plnkr fork showing this: http://plnkr.co/edit/N6vJ5b37ulfpfumAkjxs?p=preview

Atmos206 avatar Jun 16 '16 23:06 Atmos206

I can confirm the problem and that the workaround works. Thanks.

molecular avatar Jun 17 '16 13:06 molecular

@Atmos206 Thanks for the workaround!

dereklin avatar Jun 17 '16 18:06 dereklin

@dereklin No problem!

Atmos206 avatar Jun 17 '16 22:06 Atmos206