Add footer in RadGridView programmatically

10 posts, 1 answers
  1. MK
    MK avatar
    29 posts
    Member since:
    Jul 2010

    Posted 03 Aug 2010 Link to this post

    Hi All,

    How can i footers in columns of radgridview programmatically?

    Thanks
    Mahesh
  2. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 03 Aug 2010 Link to this post

    Hi Mahesh,

    in c# it would be something like :

    this.RadGridView.ShowColumnFooters = true;


    Sincerely yours,
    Pavel Pavlov
    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
  3. DevCraft banner
  4. MK
    MK avatar
    29 posts
    Member since:
    Jul 2010

    Posted 03 Aug 2010 Link to this post

    Hi Pave,

    Thanks
    But i want to add one textblock in footer using C#. How can i do?
  5. Answer
    Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 03 Aug 2010 Link to this post

    Hello,

     Here is an example:

    column.Footer = new TextBlock();

    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
  6. Nicolas Wagener
    Nicolas Wagener avatar
    6 posts
    Member since:
    Nov 2009

    Posted 26 Aug 2010 Link to this post

    Hello,

    Is it possible to put a TextBlock into the Footer ? I mean just a Texblock, not an aggregate function.

    Like this :
    TextBlock tbTest = new TextBlock() { Text="Test", Foreground = new SolidColorBrush(Colors.Red) };
    RadGridView1.Columns["Name"].Footer = tbTest;
    //RadGridView1.Columns[0].Footer = tbTest;


    I tried it without succeed.

    Thank You.
  7. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 26 Aug 2010 Link to this post

    Hi Nicolas Wagener,

    Yes, that is correct. You just need to show the column footers by setting the ShowColumnFooters property of the gridview to True.

    Also, make sure that when the code is executed the RadGridView1.Columns["Name"] is not null, e.g. the columns are already generated.

    All the best,
    Veselin Vasilev
    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
  8. Nicolas Wagener
    Nicolas Wagener avatar
    6 posts
    Member since:
    Nov 2009

    Posted 26 Aug 2010 Link to this post

    Hello,

    sorry but I'm probably missing something ...

    here is some code snippets :

    MainPage.xaml :
    <Grid x:Name="LayoutRoot">
            <Grid.RowDefinitions>
                <RowDefinition Height="30" />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Button Content="Click me" Click="Button_Click" />
            <telerikGridView:RadGridView x:Name="RadGridView1" ShowColumnFooters="True" Grid.Row="1" />
        </Grid>

    MainPage.cs :
    public partial class MainPage : UserControl
        {
            public MainPage()
            {
                InitializeComponent();
     
                RadGridView1.ItemsSource = from i in Enumerable.Range(0, 10)
                                           select new MyObject()
                                           {
                                               ID = i,
                                               Name = String.Format("Name{0}", i)
                                           };
            }
     
            private void Button_Click(object sender, RoutedEventArgs e)
            {
                TextBlock tbTest = new TextBlock() { Text="Test", Foreground = new SolidColorBrush(Colors.Red) };
     
                GridViewColumnCollection dataColumn = RadGridView1.Columns; // .ElementAt<GridViewDataColumn>(1); // ["Name"]
     
                foreach (GridViewColumn column in dataColumn)
                {
                    if(column != null)
                        column.Footer = tbTest;
                }
     
                //var countFunction = new CountFunction();
                //countFunction.FunctionName = "MyCountFunction";
                //RadGridView1.Columns["ID"].AggregateFunctions.Add(countFunction);
                //RadGridView1.Rebind();
                //RadGridView1.Columns["Name"].Footer = RadGridView1.AggregateResults["MyCountFunction"];
     
            }
        }
     
        public class MyObject
        {
            public int ID { get; set; }
            public string Name { get; set; }
        }

    When the button is clicked, my Column isn't "null" but nothing appears into the footers.

    Thanks again for your help.

    Nicolas.
  9. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 26 Aug 2010 Link to this post

    Hello Nicolas Wagener,

    Please try this:

    foreach (GridViewColumn column in clubsGrid.Columns)
    {
        if (column != null)
            column.Footer = new TextBlock()
            {
                Text = "Test",
                Foreground = new SolidColorBrush(Colors.Red)
            };
    }


    Best wishes,
    Veselin Vasilev
    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
  10. Nicolas Wagener
    Nicolas Wagener avatar
    6 posts
    Member since:
    Nov 2009

    Posted 26 Aug 2010 Link to this post

    Sorry, no changes.

    I run the last version of the binaries : RadControls for Silverlight Q2 2010 SP1.

    Nicolas.
  11. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 27 Aug 2010 Link to this post

    Hi Nicolas Wagener,

    Hm, actually I executed that code in the DataLoaded event of the gridview. Trying it in button click did not change the footer. This probably is a bug so I am logging it in the PITS: Setting the Footer on Button_Click event does not work

    I have updated your Telerik Points.

    All the best,
    Veselin Vasilev
    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
Back to Top
DevCraft banner