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

Add footer in RadGridView programmatically

9 Answers 664 Views
GridView
This is a migrated thread and some comments may be shown as answers.
MK
Top achievements
Rank 1
MK asked on 03 Aug 2010, 09:01 AM
Hi All,

How can i footers in columns of radgridview programmatically?

Thanks
Mahesh

9 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 03 Aug 2010, 09:03 AM
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
0
MK
Top achievements
Rank 1
answered on 03 Aug 2010, 09:45 AM
Hi Pave,

Thanks
But i want to add one textblock in footer using C#. How can i do?
0
Accepted
Vlad
Telerik team
answered on 03 Aug 2010, 10:00 AM
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
0
Nicolas Wagener
Top achievements
Rank 1
answered on 26 Aug 2010, 12:25 PM
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.
0
Veselin Vasilev
Telerik team
answered on 26 Aug 2010, 01:45 PM
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
0
Nicolas Wagener
Top achievements
Rank 1
answered on 26 Aug 2010, 02:24 PM
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.
0
Veselin Vasilev
Telerik team
answered on 26 Aug 2010, 02:38 PM
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
0
Nicolas Wagener
Top achievements
Rank 1
answered on 26 Aug 2010, 03:04 PM
Sorry, no changes.

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

Nicolas.
0
Veselin Vasilev
Telerik team
answered on 27 Aug 2010, 07:44 AM
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
Tags
GridView
Asked by
MK
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
MK
Top achievements
Rank 1
Vlad
Telerik team
Nicolas Wagener
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Share this question
or