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

GridViewCheckBoxColumn CheckBox Command part II

1 Answer 184 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jonathan
Top achievements
Rank 1
Jonathan asked on 21 Mar 2019, 09:32 PM

Hello I posted a question here: https://www.telerik.com/forums/gridviewcheckboxcolumn-checkbox-command#zvPzrS8xrECwPcG1wGYRTA and realized afterwards that the thread might be closed. Anyroad, I have a problem similar to the original poster. My ApprovalStatusEditCommand is not being fired. Also, as a side note, the DataMemberBinding is not necessary. Even without it the "IsChecked" bindings seem to be updating the object - even though the "IsApproved" is underlined (in Visual Studio) as "cannot resolve."

Any help resolving this would be much appreciated. Basically, I'm trying to execute a command if a checkbox (in a radgridview) is checked.

Kind regards,

Jonathan

P.S. I'm sorry if I created a duplicate post, but all my research has not really helped me work around this.

<telerik:GridViewDataColumn Header="Approved"                                                     DataMemberBinding="{Binding IsApproved, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"                                                     Width="Auto"                                                     MinWidth="75"                                                     EditTriggers="CellClick"                                                     IsFilterable="False">                        <telerik:GridViewDataColumn.CellTemplate>                            <DataTemplate>                                <telerik:GridViewCheckBox IsChecked="{Binding IsApproved, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />                            </DataTemplate>                        </telerik:GridViewDataColumn.CellTemplate>                        <telerik:GridViewDataColumn.CellEditTemplate>                            <DataTemplate>                                <CheckBox IsChecked="{Binding IsApproved, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"                                     Command="{Binding ApprovalStatusEditCommand, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />                            </DataTemplate>                        </telerik:GridViewDataColumn.CellEditTemplate>                    </telerik:GridViewDataColumn>

1 Answer, 1 is accepted

Sort by
0
Jonathan
Top achievements
Rank 1
answered on 22 Mar 2019, 07:23 PM

Got it to work:

<telerik:GridViewDataColumn Header="Approved"                                                 
DataMemberBinding="{Binding IsApproved}"                                                 Width="Auto"                                                 MinWidth="75">                        <telerik:GridViewDataColumn.CellTemplate>                            <DataTemplate>                                <CheckBox Margin="0 0 0 0"                                           HorizontalAlignment="Center"                                           d:DataContext="{d:DesignInstance timesheet:TimesheetLineItemClientModel, d:IsDesignTimeCreatable=True }"                                           IsChecked="{Binding IsApproved}"                                           CommandParameter="{Binding}"                                           Command="{Binding DataContext.ApprovalStatusEditCommand, RelativeSource={RelativeSource FindAncestor,                                     AncestorType={x:Type telerik:RadGridView}}}" />                            </DataTemplate>                        </telerik:GridViewDataColumn.CellTemplate>                    </telerik:GridViewDataColumn>

 

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