This question is locked. New answers and comments are not allowed.
I have a column in gridview with checkboxes:
| <telerikGridView:GridViewDataColumn Header="Min" DataMemberBinding = "{Binding MinimumLevel, Mode=TwoWay}" Width="5*"/> |
| <telerikGridView:GridViewDataColumn Header="Not Tracked" Width="85" IsReadOnly="True"> |
| <telerikGridView:GridViewDataColumn.CellTemplate> |
| <DataTemplate> |
| <CheckBox HorizontalAlignment="Center" Tag="{Binding pkStockItemID}" IsChecked="{Binding Composition}" Checked="CheckBox_Checked" Unchecked="CheckBox_Unchecked" VerticalAlignment="Center"/> |
| </DataTemplate> |
| </telerikGridView:GridViewDataColumn.CellTemplate> |
| </telerikGridView:GridViewDataColumn> |
Basically I need to change cell with Header="Min" to 0 when checkbox is checked and to 1 when unchecked in particular row.
Thanks.
7 Answers, 1 is accepted
0
Hello,
You can access directly your data item using DataContext property of the sender in your event handler. You need to cast however sender to CheckBox.
Sincerely yours,
Vlad
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.
You can access directly your data item using DataContext property of the sender in your event handler. You need to cast however sender to CheckBox.
Sincerely yours,
Vlad
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
Hazeest
Top achievements
Rank 1
answered on 21 Oct 2009, 10:41 AM
Can you please give me a sample code?
0
Hi,
Here is an example:
var customer = ((CheckBOx)sender).DataContext as Customer;
Kind regards,
Vlad
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.
Here is an example:
var customer = ((CheckBOx)sender).DataContext as Customer;
Kind regards,
Vlad
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
Hazeest
Top achievements
Rank 1
answered on 21 Oct 2009, 11:23 AM
Hm...
The problem is that I also need to make this cell (header=Min) disabled. Can I do this with DataContext?
0
Hello,
No, however you can access the parent cell using our powerful extension methods. Here is an example:
var cell = ((CheckBox)sender).ParentOfType<GridViewCell>()
Sincerely yours,
Vlad
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.
No, however you can access the parent cell using our powerful extension methods. Here is an example:
var cell = ((CheckBox)sender).ParentOfType<GridViewCell>()
Sincerely yours,
Vlad
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
Hazeest
Top achievements
Rank 1
answered on 21 Oct 2009, 12:55 PM
It says: 'System.Windows.Controls.CheckBox' does not contain a definition for 'ParentOfType' and no extension method 'ParentOfType' accepting a first argument of type 'System.Windows.Controls.CheckBox' could be found (are you missing a using directive or an assembly reference?)
I also tried to do an example from the blog:
1) Get all grid rows:
var rows = RadGridView1.ChildrenOfType<GridViewRow>();
var rows = RadGridView1.ChildrenOfType<GridViewRow>();
Error: 'Telerik.Windows.Controls.RadGridView' does not contain a definition for 'ChildrenOfType' and no extension method 'ChildrenOfType' accepting a first argument of type 'Telerik.Windows.Controls.RadGridView' could be found (are you missing a using directive or an assembly reference?)
I'am using 2009 Q3 Beta controls if it helps.
0
Accepted
Hello,
Since these are extension methods from Telerik.Windows.Controls namespace you need to register this namespace.
Greetings,
Vlad
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.
Since these are extension methods from Telerik.Windows.Controls namespace you need to register this namespace.
Greetings,
Vlad
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.
