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

GridViewSelectColumn check programmatically

5 Answers 399 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Globanet
Top achievements
Rank 1
Globanet asked on 13 Nov 2012, 12:12 PM
Hello, 

I have a RadGridView with select column and items that are binded to this grid have boolean field named IsChecked. I want to write binding that will check\uncheck checkbox in GridViewSelectColumn depending on item's IsChecked property value. I tried everything I found in google, but no luck. 
Any help will be appreciated.

Thanks

5 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 13 Nov 2012, 04:04 PM
Hello,

Please note that this column is bound (TwoWay) to the IsSelected property of the rows. Is your IsChecked property bound to it as well?

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Globanet
Top achievements
Rank 1
answered on 15 Nov 2012, 09:07 AM
Hi, thank you for your reply

I am using this code to achieve required functionality :

<telerik:RadGridView.RowStyle>
  <Style TargetType="telerik:GridViewRow">
    <Setter Property="IsSelected" Value="{Binding IsChecked}"/>
  </Style>
</telerik:RadGridView.RowStyle>

It works, but it only selects rows that are visible, i.e. if I have 20 rows in my grid, and only 5 of them are visible without scrolling down when window opens and I want to select 10 rows, only this 5 visible rows are selected. How can I work around this situation? 

Thanks
0
Dimitrina
Telerik team
answered on 16 Nov 2012, 03:36 PM
Hello,

Indeed the binding to IsSelected will not work for the not visible rows as they still do not exist.

I would suggest you to work with the SelectedItems collection of the GridView directly rather then relying on the IsSelected property of the GridViewRow. Do you think that such an approach could be applied to your scenario?

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Globanet
Top achievements
Rank 1
answered on 20 Nov 2012, 08:21 AM
Hi,

I tried using SelectedItems collection but I have an exception saying that this property has no setter. How can I set this collection?

0
Dimitrina
Telerik team
answered on 20 Nov 2012, 08:27 AM
Hello,

You could take a look at this forum thread showing how to bind the SelectedItems collection of the RadGridView to a property in your ViewModel. 

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

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