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

Unale to get control from header style.

8 Answers 71 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Nandkishor Phalke
Top achievements
Rank 1
Nandkishor Phalke asked on 26 Jul 2010, 10:44 AM
hello ,

        I am using Radgridview.
        I have to show hyperlink in column header . 
        I have created a style and assigned to header style.
        I want to get that hyperlinkbutton at runtime and have to chnage its containt . 

      Style :
 

<

 

 

Style x:Key="CompanyHeaderStyle" TargetType="gridViewElements:GridViewHeaderCell">

 

 

 

 

<Setter Property="Template" >

 

 

 

 

<Setter.Value>

 

 

 

 

<ControlTemplate >

 

 

 

 

<Grid MouseLeftButtonDown="header_MouseLeftButtonDown" HorizontalAlignment="Stretch" >

 

 

 

 

<Grid.RowDefinitions>

 

 

 

 

<RowDefinition />

 

 

 

 

</Grid.RowDefinitions>

 

 

 

 

<HyperlinkButton x:Name="lnkCompanyNameInStyle" Content="Select Company to Compare"

 

 

 

HorizontalAlignment="Center" Click="lnkCompanyNameInStyle_Click"

 

 

 

Loaded="lnkCompanyNameInStyle_Loaded" Tag="0"

 

 

 

IsTabStop="False">

 

 

 

 

</HyperlinkButton>

 

 

 

 

 

 

</Grid>

 

 

 

 

</ControlTemplate>

 

 

 

 

</Setter.Value>

 

 

 

 

</Setter>

 


I have triend visualtreehelper but was not successful .

Thanks , 
Nandkishor


  

8 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 26 Jul 2010, 01:37 PM
Hello Nandkishor Phalke,

I suggest you to place this HyperlinkButton inside a GridViewDataColumn's Header property directly:
<telerikGrid:RadGridView x:Name="radGridView1" Width="450" Height="450"......>
<telerikGrid:RadGridView.Columns>
<telerikGrid:GridViewDataColumn ......>
<telerikGrid:GridViewDataColumn.Header>
<Grid>
<HyperlinkButton x:Name="lnkCompanyNameInStyle" Content="Select Company to Compare".../>
</Grid>
</telerikGrid:GridViewDataColumn.Header>
</telerikGrid:GridViewDataColumn>
</telerikGrid:RadGridView.Columns>
</telerikGrid:RadGridView>
 
All the best,
Vanya Pavlova
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
Nandkishor Phalke
Top achievements
Rank 1
answered on 26 Jul 2010, 02:39 PM
Hello Vanya ,

Thanks for reply ,

I am adding column at code behind .
how can i do that in code behind .

Nandkishor.
0
Accepted
Vlad
Telerik team
answered on 26 Jul 2010, 02:40 PM
Hi Nandkishor Phalke,

Since Header property is object you can add anything. For example:

column.Header = new HyperlinkButton();

All the best,
Vlad
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
Nandkishor Phalke
Top achievements
Rank 1
answered on 26 Jul 2010, 02:55 PM
Thanks :)
0
Sajjad Shah
Top achievements
Rank 1
answered on 12 Aug 2010, 01:52 PM
What if you have a bunch of column headers with checkboxes in them. And then wihin a function you wanted to loop through all of the header cells and find out the lable of those which are checked..What's way to fo this ?
0
Vanya Pavlova
Telerik team
answered on 12 Aug 2010, 04:00 PM
Hello Sajjad Shah,

Could you please take a look at this forum thread:CheckboxInGridView.
Generally you could add the checkbox as it is shown in the previous post and using our extension method ChildrenOfType to extract the checkBoxes and determine whether it is checked or not,you can find more info about this here.
Please let me know if I can assist you further.

All the best,
Vanya Pavlova
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
Sajjad Shah
Top achievements
Rank 1
answered on 12 Aug 2010, 04:26 PM
Thanks. This part I had worked out already and got it to work. I have another question. I am trying to automatcally check the checkboxes on the column header. I am using Style for checkboxes on the column header. I have a web service (WCF) which brings the data and the columns get defined. I have to check few boxes by default (when user looks at the the screen). Although my logic to check tick the checboxes comes after the service call return. My number of columns are still not expected as what i want them to be. Is there any specifc event i should be after which gets fired after the column count on the grid is : what i expect it to be.

Thanks.
0
Vlad
Telerik team
answered on 13 Aug 2010, 07:02 AM
Hello,

You can cast desired column Header property to CheckBox and set desired properties. 

Kind regards,
Vlad
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
Nandkishor Phalke
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Nandkishor Phalke
Top achievements
Rank 1
Vlad
Telerik team
Sajjad Shah
Top achievements
Rank 1
Share this question
or