Anton Samarin
Top achievements
Rank 1
Anton Samarin
asked on 26 Feb 2009, 12:40 PM
Hello,
Can I put the property read-only only for a single cell in a row and not to the entire column?
I want to change this value depending on the remaining cells in row.
Thanks.
5 Answers, 1 is accepted
0
Accepted
Hi Anton,
Sincerely yours,
Jordan
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
You can use GridViewCell PreviewEditStartedEvent to cancel editing of some row and simulate read-only cells.
public partial class Example |
{ |
public Example() |
{ |
this.InitializeComponent(); |
this.radGridView.AddHandler(GridViewCell.PreviewEditStartEvent, new EventHandler<CellCancelRoutedEventArgs>(PreviewEditStartEventHandler)); |
} |
private void PreviewEditStartEventHandler(object sender, CellCancelRoutedEventArgs e) |
{ |
// some custom logic |
e.Cancel = true; |
} |
} |
Sincerely yours,
Jordan
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
michael mccurrey
Top achievements
Rank 1
answered on 06 Aug 2009, 06:19 PM
Is there a way to do this via a DataTrigger via XAML?
0
Hello michael mccurrey,
Generally, IsReadOnly property can be set only on a GridViewDataColumn and RadGridView objects. Since GridViewCell do not have IsReadOnly property you cannot set this via xaml. A possible solution is to use GridViewCell.IsEnabled property in the following way:
Hope this helps.
Greetings,
Nedyalko Nikolov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Generally, IsReadOnly property can be set only on a GridViewDataColumn and RadGridView objects. Since GridViewCell do not have IsReadOnly property you cannot set this via xaml. A possible solution is to use GridViewCell.IsEnabled property in the following way:
<Grid.Resources> |
<Style x:Key="customCellStyle" TargetType="grid:GridViewCell"> |
<Style.Triggers> |
<DataTrigger Binding="{Binding IsReadOnly}" Value="True"> |
<Setter Property="IsEnabled" Value="False" /> |
</DataTrigger> |
</Style.Triggers> |
</Style> |
</Grid.Resources> |
<telerik:RadGridView x:Name="radGridView" AutoGenerateColumns="False"> |
<telerik:RadGridView.Columns> |
<telerik:GridViewDataColumn UniqueName="FirstName" CellStyle="{StaticResource customCellStyle}" /> |
</telerik:RadGridView.Columns> |
</telerik:RadGridView> |
Hope this helps.
Greetings,
Nedyalko Nikolov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Hello michael mccurrey,
With the 2009.Q3 version and above you can cancel edit for a particular GridViewCell (make cell read-only for the end user) by using RadGridView.BeginningEdit event which replaced GridViewCell.PreviewEditStartEvent with a code similar to following:
All the best,
Nedyalko Nikolov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
With the 2009.Q3 version and above you can cancel edit for a particular GridViewCell (make cell read-only for the end user) by using RadGridView.BeginningEdit event which replaced GridViewCell.PreviewEditStartEvent with a code similar to following:
void
radGridView_BeginningEdit(
object
sender, GridViewBeginningEditRoutedEventArgs e)
{
if
(e.Cell.Column.UniqueName ==
"FirstName"
)
{
e.Cancel =
true
;
}
}
All the best,
Nedyalko Nikolov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Ganapathi
Top achievements
Rank 1
answered on 21 Oct 2015, 03:59 PM
Even you can do like this.....
if (!(e.Row is GridViewRow)) return;
var cells = (e.Row as GridViewRow).Cells.OfType<GridViewCell>();
foreach (var cell in cells)
{
if (cell.Value.ToString().Equals("String"))
{
e.Cancel = true;
}
}