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

Select row on button click

3 Answers 69 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Levon
Top achievements
Rank 1
Levon asked on 23 May 2013, 08:17 AM
Hi,
when i click on the row it is highlighted, but the IsSelected property is not changed! 
How can I achieve the goal without braking the MVVM pattern?

Firstly I had a column with a checkbox, which was bound to the IsSelected Property, with a Mode=TwoWay, it worked ok, only if I clicked the specified column, but I want to have the result clicking anywhere in the row.

3 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 23 May 2013, 09:47 AM
Hi,

Actually the GridView already has such a column - GridViewSelectColumn. Would you please check it and let me know if it covers your requirements?

Regards,
Didie
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Levon
Top achievements
Rank 1
answered on 23 May 2013, 10:37 AM
I have code like this: 
<telerik:RadGridView.Columns>
    <telerik:GridViewColumn   Header=""
                     IsFilterable="False"
                     IsSortable="False"
                     IsReadOnly="True"
                     HeaderCellStyle="{StaticResource GridViewDefaultCheckboxStyles}">
        <telerik:GridViewColumn.CellTemplate>
            <DataTemplate>
                <CheckBox IsChecked="{Binding IsSelected, Mode=TwoWay}"
                          Style="{StaticResource GridCheckBoxStyle}">
                </CheckBox>
            </DataTemplate>
        </telerik:GridViewColumn.CellTemplate>
    </telerik:GridViewColumn>
    <!--Other columns-->
</telerik:RadGridView.Columns>

When I click into the checkbox everything works well,
and I can take the selected item from my model.
But now I want it to work everywhere I click in the row.
I don't know how to bind my IsSelected property to the row selection change!

Thank you,
Levon
0
Accepted
Dimitrina
Telerik team
answered on 27 May 2013, 03:22 PM
Hi,

Together with the column, you should add a Style targeting GridViewRow. Similar to:

<Style TargetType="telerik:GridViewRow">
    <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/>
</Style>

I hope this helps.

Regards,
Didie
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Levon
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Levon
Top achievements
Rank 1
Share this question
or