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

All rows of dataGrid tobe selected by default.

3 Answers 113 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rahul
Top achievements
Rank 1
Rahul asked on 19 Jan 2011, 06:53 AM
Hi,
I need a all rows of dataGrid tobe selected by default.
How we can achive this.

 

 

 

<telerik:GridViewSelectColumn Header="Select" x:Name="chkbox" />

 


3 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 19 Jan 2011, 11:10 AM
Hello Rahul,

May you provide a bit more details about requirements ? Why do you want to set all items as selected initially ? Do you want to change only the visual state of the items or you want to use the SelectedItems afterwards ? 

Greetings,
Maya
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Rahul
Top achievements
Rank 1
answered on 19 Jan 2011, 11:18 AM
Hello Maya ,

I have requirement like all rows of datagrid should be selected on page load itself.

I need to use the selected items afterwords.
0
Maya
Telerik team
answered on 19 Jan 2011, 03:53 PM
Hello Rahul,

You may add all the items from the Items collection of the grid to the SelectedItems collection during the Loaded event:

void playersGrid_Loaded(object sender, RoutedEventArgs e)
        {
            foreach(Player player in this.playersGrid.Items)
            {
                this.playersGrid.SelectedItems.Add(player);
            }
        }

Another possible approach would be to follow the idea demonstrated in this blog post.  

All the best,
Maya
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Tags
GridView
Asked by
Rahul
Top achievements
Rank 1
Answers by
Maya
Telerik team
Rahul
Top achievements
Rank 1
Share this question
or