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

Customize GridView Through a Control Template

9 Answers 54 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ricardo Peres
Top achievements
Rank 1
Ricardo Peres asked on 25 Apr 2015, 08:00 PM

Hi,

I was trying to customize the RadGridView by using a control template. Basically, I wanted to always include an additional control together with the grid.

The first thing I noticed was, the ContentPresenter control doesn't do what it should, that is, the RadGridView does not get rendered. Then I tried to add another RadGridView to the control template, and have its properties bound to the container RadGridView through TemplateBindings or Bindings, but, for example, I cannot do this for the columns.

Has anyone succeeded in doing this? If so, what is the best approach? Could visual states be the answer?

Thanks,

RP

9 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 29 Apr 2015, 12:59 PM
Hello Ricardo,


There is an option to add some custom content via predefining the template of RadGridView
However it depends where this custom content should be placed - either inside or outside of GridViewScrollViewer

Can you please verify this one?

Based on this info I will prepare small sample project, which illustrates the desired approach. 



Regards,
Vanya Pavlova
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Ricardo Peres
Top achievements
Rank 1
answered on 29 Apr 2015, 03:22 PM

Hi, Vanya!

Thanks for your reply! What I was looking was a way to have a RadProgressBar at the bottom (outside) of the RadGridView that, depending on some condition, would appear as to indicate that the grid's content was loading.

Can you do that?

Thanks!

RP

0
Vanya Pavlova
Telerik team
answered on 30 Apr 2015, 01:18 PM
Hello Ricardo,


You may define simple layout with RadGridView and RadProgressBar similar to the following:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
        <RowDefinition Height="auto"/>
         </Grid.RowDefinitions>
         <telerik:RadGridView ItemsSource="{Binding Collection}"/>
         <telerik:RadProgressBar Grid.Row="1"/>
</Grid>

Then you could bind Visibility property of the progress bar to some property of your view model. 
Using this approach you do not have to predefine the template of RadGridView to achieve the desired effect. 


Regards,
Vanya Pavlova
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Ricardo Peres
Top achievements
Rank 1
answered on 30 Apr 2015, 01:24 PM

Hi, Vanya!

Yes, I know that! :-)

But what I wanted to do was, in *every location* where I have a RadGridView, also have the RadProgressBar. And I think the only way is through a control template (or subclassing, but by subclassing I can't be sure that I can add the RadProgressBar below the RadGridView).

 

RP

0
Vanya Pavlova
Telerik team
answered on 30 Apr 2015, 01:58 PM
Hi Ricardo,


You may find attached sample demo that illustrates how to embed a progress bar within the template of RadGridView
Hope this helps. 


Regards,
Vanya Pavlova
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Ricardo Peres
Top achievements
Rank 1
answered on 30 Apr 2015, 02:27 PM

Hello again!

Thanks for your example, but I already knew how to do that... it works for automatically created columns, but not for explicitly declared ones. I mentioned that on my first post.

RP

0
Accepted
Vanya Pavlova
Telerik team
answered on 30 Apr 2015, 02:36 PM
Hello Ricardo,


Since the progress bar is outside of the grid's scrollviewer it does not matter how you define the columns. All columns are inside RadGridView's GridViewScrollViewer. In order to avoid any additional round trips please share with us some snapshot with the desired final result. 

I look forward to hearing from you. 


Regards,
Vanya Pavlova
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Ricardo Peres
Top achievements
Rank 1
answered on 30 Apr 2015, 02:45 PM

Well, I don't have a screenshot, but I don't think you understood my problem! :-)

If I specify some columns, say:

<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Property1}"/>
<telerik:GridViewCheckBoxColumn DataMemberBinding="{Binding Property2}"/>
</telerik:RadGridView.Columns>

 It does show these two columns, but appends all of the automatically columns to the grid, which is what I don't want.

 RP

0
Ricardo Peres
Top achievements
Rank 1
answered on 30 Apr 2015, 02:47 PM

Sorry, it does work! I just need to set AutoGenerateColumns to False!

Thanks for your help! I really apreciate it!

Best regards,

RP

Tags
GridView
Asked by
Ricardo Peres
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Ricardo Peres
Top achievements
Rank 1
Share this question
or