Customize GridView Through a Control Template

10 posts, 1 answers
  1. Ricardo Peres
    Ricardo Peres avatar
    6 posts
    Member since:
    Oct 2009

    Posted 25 Apr 2015 Link to this post

    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

  2. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 29 Apr 2015 Link to this post

    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.

     
  3. DevCraft banner
  4. Ricardo Peres
    Ricardo Peres avatar
    6 posts
    Member since:
    Oct 2009

    Posted 29 Apr 2015 in reply to Vanya Pavlova Link to this post

    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

  5. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 30 Apr 2015 Link to this post

    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.

     
  6. Ricardo Peres
    Ricardo Peres avatar
    6 posts
    Member since:
    Oct 2009

    Posted 30 Apr 2015 in reply to Vanya Pavlova Link to this post

    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

  7. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 30 Apr 2015 Link to this post

    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.

     
  8. Ricardo Peres
    Ricardo Peres avatar
    6 posts
    Member since:
    Oct 2009

    Posted 30 Apr 2015 in reply to Vanya Pavlova Link to this post

    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

  9. Answer
    Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 30 Apr 2015 Link to this post

    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.

     
  10. Ricardo Peres
    Ricardo Peres avatar
    6 posts
    Member since:
    Oct 2009

    Posted 30 Apr 2015 in reply to Vanya Pavlova Link to this post

    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

  11. Ricardo Peres
    Ricardo Peres avatar
    6 posts
    Member since:
    Oct 2009

    Posted 30 Apr 2015 in reply to Ricardo Peres Link to this post

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

    Thanks for your help! I really apreciate it!

    Best regards,

    RP

Back to Top
DevCraft banner