I have a table with multiple columns. I want content of each column to be selected individually. When I start selecting first column, second, third ... are automatically getting selected. When I select one column I want make other columns non selectable.
I have tried applying following class on elements and it worked fine in FF.No matter where you start selection from, its never selectable.
.unselectable {
user-select: none; /* CSS3 */
-moz-user-select: none;
-khtml-user-select: none;
}
For IE I have tried property called unselectable="on"
, In Internet Explorer, it is still selectable if the selection starts outside. I want to prevent selection of certain columns even selection starts from outside.
I have tried using onselectionstart and onmouseover but as the selection is starting outside of element these are not getting triggered.
Do I have any hope ?
Thanks in advance.
To hide a column entirely from view, meaning it will not be displayed in either the normal or details row, simply use the visible column option and set it to false . This example shows a table where the first column ID is completely hidden from view using the data-visible column attribute.
In Mozilla Firefox, users may highlight only certain rows, columns, or cells of an HTML table by holding down the Ctrl on the keyboard and click each cell individually.
Cells within HTML tables can span multiple rows and multiple columns. The cell default is one row and one column. However, with the ROWSPAN attribute a cell can span more than one row, and with the COLSPAN attribute a cell can span more than one column.
Use the style attribute with the width or height properties to specify the size of a table, row or column.
I believe that for now there is no pure CSS solution.
It may sound weird, but you could clone the content of the column you want the user to select into a separate table that will be positioned: absolutely
over the original column.
Instead of reinventing the wheel... check out http://www.datatables.net/
This is a JQuery table plug-in that'll knock your socks off.
It looks like it is already doing what you would like to do and it is free.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With