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

How to select the cells of a particular column on header click

9 Answers 122 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ashish
Top achievements
Rank 1
Ashish asked on 26 Jun 2010, 12:13 PM
Hello All,

I want to select the cells of a particular column over the header click of that column. Please suggest me how to achieve this task?

Regards

Ashish

9 Answers, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 28 Jun 2010, 07:39 PM
Hello Ashish,

Cell selection is not sported in the version that you have downloaded. Cell selection will be introduced with our upcoming Q2 release. Unfortunately columns selection will not be supported out of the box probably until the first service pack of Q2. 

Still, column selection will be possible with a bit of customization.


Kind regards,
Milan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Ashish
Top achievements
Rank 1
answered on 29 Jun 2010, 06:30 AM
Hello Milan,

I can trace the click on the header of a column, but unable to select the cells as the grid is binded to a datacontext and the rows are shown as of that data context. As you mentioned this can be done with a bit of customization. Could you please help me to send me any sample code for this task?

Regards

Ashish
0
Milan
Telerik team
answered on 30 Jun 2010, 04:24 PM
Hello Ashish,

Unfortunately I will not be able to send you a sample code since the functionality that I am about to talk about is not available in our beta releases .

With Q2 the SelectedCells collection will have a method called AddRange which will allow you to select a range of cells. When a header is clicked you will be able to call AddRange to select all cells of the respective column.

For the time being this is the only information that I can share. 


Greetings,
Milan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Pinak
Top achievements
Rank 1
answered on 16 Aug 2010, 03:18 PM
Hi Milan,

I am also looking for the same functionality.
I have a latest build Q2 2010.
However SelectedCells collection does not have a method called AddRange.

Could you please send a sample project, how to customize it?

Thanks,
Pinak Desai
0
Yavor Georgiev
Telerik team
answered on 16 Aug 2010, 04:14 PM
Hi Pinak,

 Unfortunately, due to higher-priority issues, exposing the AddRange method has been postponed. However, you can easily select all the cells in a column like so:

foreach (var item in this.gridView.Items)
{
    var cellInfo = new GridViewCellInfo(item, this.gridView.Columns[3], this.gridView);
    this.gridView.SelectedCells.Add(cellInfo);
}

Sincerely yours,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Pinak
Top achievements
Rank 1
answered on 16 Aug 2010, 04:31 PM
Thanks Yavor.

Could you also please send me a code snippet, how can I inject a button / image into HeaderRow and how can I validate which button has been clicked?

I have a grid with 50 columns and AutoGenerateColumns="true".
Now I want to give users an ability to select the cell of perticular column on header selection without affecting sort functionality.
so I am thinking to provide button or image. what you suggest?

 

0
Yavor Georgiev
Telerik team
answered on 16 Aug 2010, 04:33 PM
Hi Pinak,

 You can set the Header property of a GridViewColumn to a UIElement, such as a button, and it'll show up in the header.

Sincerely yours,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Pinak
Top achievements
Rank 1
answered on 16 Aug 2010, 04:48 PM
Hi Yavor,

I didn't get your solution.

I want both button and HeaderText inside the Header, and I don't want to write like following code inside my xaml otherwise I have to repeat it for as many columns I have. As I said earlier I have autogeneratedcolumns set to true.

 

 

 

<telerikGrid:GridViewDataColumn.Header>

 

 

 

 

<StackPanel>

 

 

 

 

<TextBlock Text="Full Name"/>

 

 

 

 

<Button x:Name="ColumnSelector" Height="20" Click="ColumnSelector_Click"></Button>

 

 

 

 

</StackPanel>

 

 

 

 

</telerikGrid:GridViewDataColumn.Header>

 

0
Yavor Georgiev
Telerik team
answered on 17 Aug 2010, 12:14 PM
Hello Pinak,

 Check out the attached project. It modifies the template of GridViewHeaderCell to add a new button, which toggles selection of the cells in the column.

All the best,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Ashish
Top achievements
Rank 1
Answers by
Milan
Telerik team
Ashish
Top achievements
Rank 1
Pinak
Top achievements
Rank 1
Yavor Georgiev
Telerik team
Share this question
or