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

[Solved] Preventing selection in RadDataGrid columns / cells

4 Answers 130 Views
Grid for XAML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Yuri
Top achievements
Rank 1
Yuri asked on 13 Jun 2013, 06:54 PM
Is there any way to make a column, or its individual cells (with SelectionMode="Single" and SelectionUnit="Cell"), non-selectable?
The idea is for the user to be able to select a cell in any column other than the first one.

4 Answers, 1 is accepted

Sort by
0
Ivaylo Gergov
Telerik team
answered on 17 Jun 2013, 10:54 AM
Hello Yuri,

Thank you for contacting us.

In this scenario, you can take advantage of the CellTap Command of the RadDataGrid. As you can see in the help article, the CanExecute(and also the Execute) method receives a parameter of type DataGridCellInfo that exposes a Column property. Thus, you can return false when the cell is from the first column. Note, that in the Execute method you need to execute the default command like this:
this.Owner.CommandService.ExecuteDefaultCommand(CommandId.CellTap, parameter);

I hope this helps. Let me know if I can assist you in some other way.

Regards,
Ivaylo Gergov
Telerik
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
0
Yiqing
Top achievements
Rank 1
answered on 25 Jul 2013, 05:57 PM
Hi Ivaylo,

I see 'Column' in DataGridCellInfo, but it is returned as DataGridColumn type. I wonder how can I get to know which specific column it is?


Thanks,
Yiqing
0
Yiqing
Top achievements
Rank 1
answered on 25 Jul 2013, 05:57 PM
Hi Ivaylo,

I see 'Column' in DataGridCellInfo, but it is returned as DataGridColumn type. I wonder how can I get to know which specific column it is?


Thanks,
Yiqing
0
Ivaylo Gergov
Telerik team
answered on 26 Jul 2013, 03:32 PM
Hello Yiqing,

In this case you can use several approaches:
  • get the Header of the column:
var header = (parameter as DataGridCellInfo).Column.Header;

  • get the Name of the column which is unique:
var name = (parameter as DataGridCellInfo).Column.Name;

  • get the index of the column in the RadDataGrid.Columns collection:
var index = this.Owner.Columns.IndexOf((parameter as DataGridCellInfo).Column);

I hope this is useful.

 

Regards,
Ivaylo Gergov
Telerik
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
Tags
Grid for XAML
Asked by
Yuri
Top achievements
Rank 1
Answers by
Ivaylo Gergov
Telerik team
Yiqing
Top achievements
Rank 1
Share this question
or