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

Problem with selecting a group of rows.

1 Answer 92 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Adam
Top achievements
Rank 1
Adam asked on 04 Jul 2013, 03:42 PM
Hi,

I've got some problem with RadGridView.
I want select all rows in one group of records. 
The problem is when I select whole group by clicking one of the record, the
whole group is selected correctly, but when I click one row twice only one
of the rows from the group is selected. It's made programmability by own
method, is there any event that selects and deselect whole group, can you
give me some advice how to make it programmability? 

Adam

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 09 Jul 2013, 03:18 PM
Hello Adam,

Thank you for writing.

I am not sure that I have understood your scenario, and especially how you are selecting whole group by a single click. I have prepared a demo project where you can select the entire group and the group will remain selected when you click a row in it. 
In the demo I am using the CurrentRowChanged to select the rows in the group like this:
void radGridView1_CurrentRowChanged(object sender, Telerik.WinControls.UI.CurrentRowChangedEventArgs e)
{
    if (radGridView1.Columns["col3"].IsGrouped)
    {
        foreach (var row in radGridView1.Rows)
        {
            if ( e.CurrentRow!=null && e.CurrentRow.Cells[2].Value == row.Cells[2].Value)
            {
                row.IsCurrent = true;
            }
            else
            {
                row.IsCurrent = false;
            }
        }
    }
}

Also the selection needs to be cleared when the rows are no longer grouped. We can do this in the GroupByChanging event:
void radGridView1_GroupByChanging(object sender, Telerik.WinControls.UI.GridViewCollectionChangingEventArgs e
{
    foreach (var row in radGridView1.Rows)
    {
 
        row.IsCurrent = false;
    }
     
}
  
If the demo does not fit in your case, please provide me with more detailed information about what you need to accomplish.

I am looking forward to your reply.

Regards,
Dimitar
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
Adam
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or