Custom Column not selectable in RadGridView

0 Answers 104 Views
GridView
Licensing
Top achievements
Rank 1
Licensing asked on 06 Dec 2022, 12:29 PM

Hi,

We have an issue with a custom column we used in RadGridView.

 

There is a scenario when a column, hence a whole row is not selectable. Please see the attached sample solution and follow below scenario:

1. Scroll to Col5 which is editable,

2. Edit Col5 value

3. Click a column next to Col5 in the same row (to accept the value in Col5 cell),

4. Scroll to the left to see Id column

5. Select the row by clicking on Id cell In the same row.

The issue is that the row is not possible to be selected nor the checkbox in the column is ticked.

 

Can you advise?

Thanks,

Łukasz

Martin Ivanov
Telerik team
commented on 07 Dec 2022, 09:17 AM

The selection in GridView relies partially on the the mouse events of the GridViewCell elements. Setting IsHitTestVisible to False (in the CreateCellElement override in this case), prevents the mouse events to be thrown for this element, thus the selection won't work until the current row is changed.

To resolve the issue avoid setting IsHitTestVisible to false. Also, if you tell me why do you need this, I can think of some alternative ideas.

Licensing
Top achievements
Rank 1
commented on 14 Dec 2022, 09:25 AM

Hi, I could remove it, as it is a workaround for disappearing checkbox in the custom column, but then there is another issue.

Try clicking multiple times the cell of the custom column where the checkbox is located. the checkbox will disappear after some amount of clicks.

Can you advise?

Licensing
Top achievements
Rank 1
commented on 20 Dec 2022, 07:59 AM

Hi, 

Have you seen my response? Can you provide any update?

Thanks,

Łukasz

Martin Ivanov
Telerik team
commented on 21 Dec 2022, 03:08 PM

I was able to reproduce the described behavior, but I am not sure if this is the same issue on your side. The number of clicks didn't matter on my side. Instead, the checkbox disappears if I click near the borders of the cell. For example, when I click on the bottom border. This happens because the cell  has two visuals - one for the normal state and one for the edit state. When you click outside of the checkbox (near the border), the cell enters edit mode, which is why the checkbox is replaced by a default empty editor. If this is the same issue as the reported one, then you can avoid it by disabling the editing of the cells in the CustomColumn.

So, you can set IsHitTestVisible to True (or not setting it at all, because True is the default value) and then set the EditTriggers of the column to None.

public CustomColumn()
	: base()
{
	EditTriggers = GridViewEditTriggers.None;
}

Licensing
Top achievements
Rank 1
commented on 26 Dec 2022, 10:59 AM | edited

Edit: Unfortunately, after the change when I click the checkbox/cell with checkbox, it still does disappear.

See the updated solution 

Martin Ivanov
Telerik team
commented on 28 Dec 2022, 09:59 AM

Thank you for the project. I've tested it, but couldn't reproduce the described issue. Can you send over a video showing what exactly is happening?
Licensing
Top achievements
Rank 1
commented on 29 Dec 2022, 07:44 AM

The issue is the same as you described. The scenario is as follows:

1. Edit value in Column 5,

2. Click the cell in Column 6 in the same row to accept the new value in Column 5,

3. Click the border of checkbox cell in the same row,

4. The checkbox disappears

 

Martin Ivanov
Telerik team
commented on 29 Dec 2022, 11:26 AM

Thank you for the steps. Based on them, I've managed to recreate the issue. An alternative solution that seems to work here is to override the CanEdit method of the column and return false.

public class CustomColumn: GridViewBoundColumnBase
{
	public override bool CanEdit(object item)
	{
		return false;
	}

	// other code here
}

Licensing
Top achievements
Rank 1
commented on 03 Jan 2023, 06:57 AM

Thanks, it is working now

No answers yet. Maybe you can help?

Tags
GridView
Asked by
Licensing
Top achievements
Rank 1
Share this question
or