This is a migrated thread and some comments may be shown as answers.

How to not allow user to select / highlight text in the grid

4 Answers 73 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dave Ranck
Top achievements
Rank 1
Dave Ranck asked on 23 Aug 2010, 10:41 PM
Hello,

I want to stop the grid from highlighting text when the user clicks, holds, and drags across the cell.  Is this possible?
Attached is an image of what I'm trying to avoid.
I want a single click to highligh the row (which works fine), a double click to return a postback (works fine), but don't want any text highlighted on single click / drag.

Thanks!

4 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 24 Aug 2010, 09:14 AM
Hi Mike,

Please add the following CSS rule to your page:

.RadGrid .rgRow,
.RadGrid .rgAltRow
{
    user-select:none;
    -moz-user-select:-moz-none;
}



Regards,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Dave Ranck
Top achievements
Rank 1
answered on 24 Aug 2010, 02:46 PM
Hi Dimo,

Thank you for the reply.  Unfortunately in IE8 I am still seeing the selected text when the user clicks and drags or double clicks on some text (see attached).  Everything looks good in Firefox though.  Is there something that can be added to satisfy IE 8?

Thanks again Dimo :)
0
Accepted
Dimo
Telerik team
answered on 24 Aug 2010, 03:13 PM
Hi Mike,

Due to IE's lack of support for the user-select CSS property, you can use

protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    foreach (TableCell cell in e.Item.Cells)
    {
        cell.Attributes.Add("unselectable", "on");
    }
}


Best wishes,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Dave Ranck
Top achievements
Rank 1
answered on 24 Aug 2010, 03:51 PM
Yea Dimo!! Thanks - You're the best! :)
Tags
Grid
Asked by
Dave Ranck
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Dave Ranck
Top achievements
Rank 1
Share this question
or