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

Programmatic multi-line footer totals

8 Answers 226 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 27 Sep 2012, 08:32 PM
Hi,

I'm creating a grid programmatically based on an unknown number of columns of unknown type and wish to generate multi-line footers with aggregated values. I have looked at the help page, but still not sure how to proceed.

I'm currently working in the RadGrid1_ItemDataBound method where I'm stuck at "if (e.Item is GridFooterItem)". I still need to figure out how to create the footers, populate them with text boxes, and refer to the mysterious clientID mentioned in the help article.
using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using System.Text.RegularExpressions;
 
 
public partial class Spreadsheet : System.Web.UI.Page
{
    protected global::System.Web.UI.WebControls.Literal dataRow;
 
    protected void Page_Init(object sender, System.EventArgs e)
    {
        DefineGridStructure();
    }
 
 
    protected void Page_Load(object sender, EventArgs e)
    {
 
        RadGrid grid = (RadGrid)PlaceHolder1.FindControl("RadGrid1");
        RadAjaxManager1.AjaxSettings.AddAjaxSetting(grid, grid);
 
        if (Page.IsPostBack)
        {
            Label1.Text += "Post back!! <br>";
        }
        if (!Page.IsPostBack)
        {
            Label1.Text += "Page_Load; " + DateTime.Now.ToString() + "<br>";
        }
    }
 
    private void DefineGridStructure()
    {
        RadGrid RadGrid1 = new RadGrid();
        RadGrid1.ID = "RadGrid1";
 
        System.Drawing.Color disabledBackColor = System.Drawing.Color.AliceBlue;
        System.Drawing.Color defaultBorderColor = System.Drawing.Color.Black;
 
        RadGrid1.Width = Unit.Percentage(100);
        RadGrid1.PageSize = 7;
        RadGrid1.GridLines = GridLines.Both;
        RadGrid1.AllowPaging = true;
 
        RadGrid1.AllowSorting = true;
        RadGrid1.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric;
        RadGrid1.ShowFooter = true;
        RadGrid1.AutoGenerateColumns = false;
        RadGrid1.ShowStatusBar = true;
 
        RadGrid1.DataSourceID = "ObjectDataSource1";
        RadGrid1.ItemDataBound += RadGrid1_ItemDataBound;
 
        RadGrid1.UpdateCommand += RadGrid1_UpdateCommand;
 
        RadGrid1.MasterTableView.PageSize = 7;
        RadGrid1.MasterTableView.Height = Unit.Percentage(100);
        RadGrid1.MasterTableView.DataKeyNames = new string[] { "report_id" };
        RadGrid1.MasterTableView.EditMode = GridEditMode.InPlace;
 
        GridEditCommandColumn editColumn;
        editColumn = new GridEditCommandColumn();
        editColumn.UniqueName = "EditCommandColumn";
        editColumn.ItemStyle.BackColor = disabledBackColor;
        editColumn.ItemStyle.BorderColor = defaultBorderColor;
        editColumn.ItemStyle.BorderWidth = Unit.Pixel(1);
        RadGrid1.MasterTableView.Columns.Add(editColumn);
 
        GridColumnGroup headerGroupColumn;
        GridBoundColumn boundColumn = new GridBoundColumn();
 
        boundColumn.DataField = "report_id";
        boundColumn.HeaderText = "report_id";
        boundColumn.ItemStyle.BackColor = disabledBackColor;
        boundColumn.ItemStyle.BorderColor = defaultBorderColor;
        boundColumn.ItemStyle.BorderWidth = Unit.Pixel(1);
        boundColumn.ReadOnly = true;
        RadGrid1.MasterTableView.Columns.Add(boundColumn);
 
 
        RadGrid1.MasterTableView.AllowMultiColumnSorting = true;
        RadGrid1.MasterTableView.SortExpressions.Clear();
        GridSortExpression expression = new GridSortExpression();
        expression.FieldName = "report_id";
        expression.SortOrder = GridSortOrder.Ascending;
        RadGrid1.MasterTableView.SortExpressions.AddSortExpression(expression);
 
 
 
        DataTable GroupHeaders = WastewaterGrid.GetGroupHeaders();
        DataTable Headers;
 
        foreach (DataRow groupRow in GroupHeaders.Rows)
        {
            String masterGroupName = groupRow["group_name"].ToString();
            String groupColumnHeader = groupRow["group_column_header"].ToString();
 
            Headers = WastewaterGrid.GetHeaders(masterGroupName);
 
            headerGroupColumn = new GridColumnGroup();
            headerGroupColumn.Name = masterGroupName;
            headerGroupColumn.HeaderText = groupColumnHeader;
            RadGrid1.MasterTableView.ColumnGroups.Add(headerGroupColumn);
 
            foreach (DataRow headerRow in Headers.Rows)
            {
                String groupName = headerRow["group_name"].ToString();
                String columnName = headerRow["column_name"].ToString();
                String columnHeader = headerRow["column_header"].ToString();
                String attributeType = headerRow["attribute_type"].ToString();
                String dataType = headerRow["data_type"].ToString();
                String targetValue = headerRow["target_value"].ToString();
 
                if (!groupName.Equals(masterGroupName))
                {
                    continue;
                }
 
                boundColumn = new GridBoundColumn();
                boundColumn.DataField = columnName;
                boundColumn.HeaderText = columnHeader; // where is the uniquename?
                boundColumn.ColumnGroupName = masterGroupName;
 
                if (columnName.Equals("MISDnotes"))
                {
                    boundColumn.ItemStyle.Width = Unit.Percentage(100);
                }
 
                if (!attributeType.Equals("ManualEntry"))
                {
                    boundColumn.ItemStyle.BackColor = disabledBackColor;
                    boundColumn.ReadOnly = true;
                }
 
                RadGrid1.MasterTableView.Columns.Add(boundColumn);
            }
        }
        this.PlaceHolder1.Controls.Add(RadGrid1);
    }
 
 
    public class FooterItem
    {
        private String _columnName;
        private int _count;
        private dynamic _min;
        private dynamic _max;
        private dynamic _sum;
 
        public FooterItem(String str)
        {
            _columnName = str;
            _count = 0;
        }
 
        public String columnName
        {
            get
            {
                return _columnName;
            }
            set
            {
                _columnName = value;
            }
        }
 
        public int count
        {
            get
            {
                return _count;
            }
            set
            {
                _count = value;
            }
        }
 
        public dynamic min
        {
            get
            {
                return _min;
            }
            set
            {
                _min = value;
            }
        }
 
        public dynamic max
        {
            get
            {
                return _max;
            }
            set
            {
                _max = value;
            }
        }
 
        public dynamic sum
        {
            get
            {
                return _sum;
            }
            set
            {
                _sum = value;
            }
        }
 
         
    }
 
 
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        Int32 userRole = 2;
        Int32 today = int.Parse("20110907");
        //String today = DateTime.Today.ToString("yyyyMMdd");
        String columnName;
        String attributeType;
 
        GridTableCell gridCell;
        dynamic cellText;
        Boolean cellPopped = false;
        TextBox cellTextBox;
        Dictionary<String, FooterItem> FooterAggregates = new Dictionary<String, FooterItem>();
        FooterItem footerItem;
 
        DataTable Headers = WastewaterGrid.GetHeaders();
 
        foreach (DataRow row in Headers.Rows)
        {
            columnName = row["column_name"].ToString();
            attributeType = row["attribute_type"].ToString();
 
            if (!attributeType.Contains("varchar"))
            {
                FooterAggregates.Add(columnName, new FooterItem(columnName));
            }
        }
 
 
        if (e.Item is GridDataItem)
        {
            GridDataItem gridRow = (GridDataItem)e.Item;
            Int32 ReportID = int.Parse(gridRow.GetDataKeyValue("report_id").ToString());
            System.Drawing.Color defaultBorderColor = System.Drawing.Color.Black;
            System.Drawing.Color ableBackColor = System.Drawing.Color.White;
            System.Drawing.Color disabledBackColor = System.Drawing.Color.AliceBlue;
            System.Drawing.Color ableBorderColor = System.Drawing.Color.Lime;
 
            foreach (DataRow row in Headers.Rows)
            {
                columnName = row["column_name"].ToString();
                attributeType = row["attribute_type"].ToString();
                 
                gridCell = (GridTableCell)gridRow[columnName];
                //cellText = gridCell.Text;
                cellText = ((DataRowView)gridRow.DataItem)[columnName];
 
                cellPopped = !String.IsNullOrEmpty((String)cellText);
 
                if (cellPopped)
                {
                    footerItem = FooterAggregates[columnName];
 
                    footerItem.count += 1;
 
                    if (footerItem.min == null)
                    {
                        footerItem.min = cellText;
                    }
                    else
                    {
                        if (footerItem.min > cellText)
                        {
                            footerItem.min = cellText;
                        }
                    }
 
                    if (footerItem.max == null)
                    {
                        footerItem.max = cellText;
                    }
                    else
                    {
                        if (footerItem.max < cellText)
                        {
                            footerItem.max = cellText;
                        }
                    }
 
                    if (footerItem.sum == null)
                    {
                        footerItem.sum = cellText;
                    }
                    else
                    {
                        footerItem.sum += cellText;
                    }
                }
                     
                gridCell.BorderColor = defaultBorderColor;
                gridCell.BorderWidth = Unit.Pixel(1);
 
                if (userRole == 1)
                {
 
                    if (attributeType.Equals("ManualEntry"))
                    {
                        gridCell.BackColor = ableBackColor;
                        gridCell.BorderColor = ableBorderColor;
                    }
                }
                else
                {
                    if (attributeType.Equals("ManualEntry"))
                    {
                        if (!ReportID.Equals(today))
                        {
                            if (String.IsNullOrEmpty(cellText))
                            {
                                gridCell.BackColor = ableBackColor;
                                gridCell.BorderColor = ableBorderColor;
                            }
                            else
                            {
                                gridCell.BackColor = disabledBackColor;
                            }
                        }
                        else
                        {
                            gridCell.BackColor = ableBackColor;
                            gridCell.BorderColor = ableBorderColor;
                        }
                    }
 
                    if (e.Item.IsInEditMode && !ReportID.Equals(today) && cellPopped)
                    {
                        cellTextBox = (TextBox)gridCell.Controls[0];
                        cellTextBox.BorderStyle = BorderStyle.None;
                        cellTextBox.BackColor = disabledBackColor;
                        cellTextBox.ReadOnly = true;
 
                        //Label1.Text += "EditMode::ReportID=" + ReportID + "columnName=" + columnName + "::cellText=" + cellText + " <br>";
                    }
                }
            }
        }
 
        if (e.Item is GridFooterItem)
        {
            GridFooterItem gridRow = (GridFooterItem)e.Item;
            int count = 0;
            dynamic min;
            dynamic max;
            dynamic sum;
 
            foreach (DataRow row in Headers.Rows)
            {
                columnName = row["column_name"].ToString();
                attributeType = row["attribute_type"].ToString();
 
                gridCell = (GridTableCell)gridRow[columnName];
                //cellText = gridCell.Text;
                cellText = ((DataRowView)gridRow.DataItem)[columnName];
 
                footerItem = FooterAggregates[columnName];
 
                count += footerItem.count;
 
            }
        }
    }
 
 
 
 
 
    private void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e)
    {
        Label1.Text += " Table to be updated: " + e.Item.OwnerTableView.DataMember + "<br>";
 
        GridEditableItem editedItem = e.Item as GridEditableItem;
        GridEditManager editMan = editedItem.EditManager;
 
        Int32 ReportID = int.Parse(editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["report_id"].ToString());
        String Login = "David-T420s\\davidk";
 
        foreach (GridColumn column in e.Item.OwnerTableView.RenderColumns)
        {
            if (column.UniqueName.Equals("report_id"))
            {
                continue;
            }
 
            if (column is IGridEditableColumn)
            {
                Boolean isEditable = column.IsEditable;
                String editColumnName = column.UniqueName.ToString();
                String ResultString;
 
                IGridEditableColumn editableCol = (column as IGridEditableColumn);
                if (editableCol.IsEditable)
                {
                    IGridColumnEditor editor = editMan.GetColumnEditor(editableCol);
 
                    if (editor is GridTextColumnEditor)
                    {
                        String Datum = (editor as GridTextColumnEditor).Text.Trim();
 
                        DataTable Headers = WastewaterGrid.GetHeaders();
                        foreach (DataRow row in Headers.Rows)
                        {
                            String columnName = row["column_name"].ToString();
                            String dataType = row["data_type"].ToString();
 
                            if (columnName.Equals(editColumnName))
                            {
                                ResultString = ValidateUserInput(dataType, Datum);
                                if (!ResultString.Equals("valid"))
                                {
                                    RadAjaxManager1.Alert(ResultString);
 
                                    e.Canceled = true;
                                    break;
                                }
                                else
                                {
                                    try
                                    {
                                        WastewaterGrid.UpsertDatum(ReportID, editColumnName, Datum, Login);
                                    }
                                    catch (Exception ex)
                                    {
                                        Label1.Text += "<strong>Unable to set value of column '" + column.UniqueName + "'</strong>  <br>" + ex.Message;
                                        RadAjaxManager1.Alert("Unable to set value of column: " + column.UniqueName + "; " + ex.Message);
                                        e.Canceled = true;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
 
        try
        {
            WastewaterGrid.ReCalculate(ReportID);
        }
        catch (Exception ex)
        {
            RadAjaxManager1.Alert("Unable to run ReCalculate: " + ex.Message);
            e.Canceled = true;
        }
    }
 
     
     
    private String ValidateUserInput(String dataType, String Datum)
    {
        if (String.IsNullOrEmpty(Datum))
        {
            return "valid";
        }
 
        Match match;
        String ResultString;
        String TestString;
        Int32 stringLength = Datum.Length;
 
        String IntPattern = @"^\d+$";
        RadAjaxManager1.Alert("VALIDATEUSERINPUT: dataType=\"" + dataType + "\"; Datum=\"" + Datum + "\"");
 
        switch (dataType)
        {
            case "bigint":
                match = Regex.Match(Datum, IntPattern);
                if (match.Success)
                {
                    try
                    {
                        TestString = Int64.Parse(Datum).ToString();
                    }
                    catch (OverflowException)
                    {
                        return "Overflow Exception: improper " + dataType + "format in \"" + Datum + "\"";
                    }
                }
                else
                {
                    return "Improper format: Int64";
                }
                break;
 
            case "decimal(10,2)":
                ResultString = ValidateDecimalFormat(dataType, Datum, stringLength, 10, 2);
                if (!ResultString.Equals("valid"))
                {
                    return ResultString;
                }
                else
                {
                    try
                    {
                        TestString = Decimal.Parse(Datum).ToString();
                    }
                    catch (OverflowException)
                    {
                        return "Overflow Exception: improper " + dataType + "format in \"" + Datum + "\"";
                    }
                }
                break;
            case "decimal(10,3)":
                ResultString = ValidateDecimalFormat(dataType, Datum, stringLength, 10, 3);
                if (!ResultString.Equals("valid"))
                {
                    return ResultString;
                }
                else
                {
                    try
                    {
                        TestString = Decimal.Parse(Datum).ToString();
                    }
                    catch (OverflowException)
                    {
                        return "Overflow Exception: improper " + dataType + "format in \"" + Datum + "\"";
                    }
                }
                break;
            case "decimal(4,1)":
                ResultString = ValidateDecimalFormat(dataType, Datum, stringLength, 4, 1);
                if (!ResultString.Equals("valid"))
                {
                    return ResultString;
                }
                else
                {
                    try
                    {
                        TestString = Decimal.Parse(Datum).ToString();
                    }
                    catch (OverflowException)
                    {
                        return "Overflow Exception: improper " + dataType + "format in \"" + Datum + "\"";
                    }
                }
                break;
            case "decimal(5,1)":
                ResultString = ValidateDecimalFormat(dataType, Datum, stringLength, 5, 1);
                if (!ResultString.Equals("valid"))
                {
                    return ResultString;
                }
                else
                {
                    try
                    {
                        TestString = Decimal.Parse(Datum).ToString();
                    }
                    catch (OverflowException)
                    {
                        return "Overflow Exception: improper " + dataType + "format in \"" + Datum + "\"";
                    }
                }
                break;
            case "decimal(6,1)":
                ResultString = ValidateDecimalFormat(dataType, Datum, stringLength, 6, 1);
                if (!ResultString.Equals("valid"))
                {
                    return ResultString;
                }
                else
                {
                    try
                    {
                        TestString = Decimal.Parse(Datum).ToString();
                    }
                    catch (OverflowException)
                    {
                        return "Overflow Exception: improper " + dataType + "format in \"" + Datum + "\"";
                    }
                }
                break;
            case "int":
                match = Regex.Match(Datum, IntPattern);
                if (match.Success)
                {
                    try
                    {
                        TestString = Int32.Parse(Datum).ToString();
                        //throw new CustomExceptions.
                    }
                    catch (OverflowException)
                    {
                        return "Overflow Exception: improper " + dataType + "format in \"" + Datum + "\"";
                    }
                }
                else
                {
                    return "Improper format: Int32";
                }
                break;
            case "varchar(25)":
                if (stringLength > 25)
                {
                    return "Improper " + dataType + "format in \"" + Datum + "\"";
                }
                break;
 
            case "varchar(255)":
                if (stringLength > 255)
                {
                    return "Improper " + dataType + "format in \"" + Datum + "\"";
                }
                break;
            default:
                RadAjaxManager1.Alert("Unhandled data type");
                return "Unhandled data type: \"" + dataType + "\"";
        }
        return "valid";
    }
 
    private String ValidateDecimalFormat(String dataType, String Datum, int stringLength, int precision, int scale)
    {
        Match match;
        String IntPattern = @"^\d+$";
        String ResultString;
        Int32 decimalIndex = Datum.IndexOf(".");
 
        if (decimalIndex > 0)
        {
            Int32 fractionalLength = stringLength - decimalIndex - 1;
 
            if (fractionalLength > scale)
            {
                return "Improper " + dataType + "format in \"" + Datum + "\"";
            }
 
            Int32 integralLength = stringLength - fractionalLength - 1;
 
            if (integralLength > (precision - scale))
            {
                return "Improper " + dataType + "format in \"" + Datum + "\"";
            }
 
            String integralString = Datum.Substring(0, decimalIndex);
            String fractionalString = Datum.Substring(decimalIndex + 1, fractionalLength);
            match = Regex.Match(integralString, IntPattern);
            if (match.Success)
            {
                match = Regex.Match(fractionalString, IntPattern);
                if (match.Success)
                {
                    ResultString = "valid";
                }
                else
                {
                    ResultString = "Improper " + dataType + "format in \"" + Datum + "\"";
                }
            }
            else
            {
                ResultString = "Improper " + dataType + "format in \"" + Datum + "\"";
            }
 
        }
        else if (stringLength > (precision - scale))
        {
            ResultString = "Improper " + dataType + "format in \"" + Datum + "\"";
        }
        else
        {
            match = Regex.Match(Datum, IntPattern);
            if (match.Success)
            {
                ResultString = "valid";
            }
            else
            {
                ResultString = "Improper " + dataType + "format in \"" + Datum + "\"";
            }
        }
 
        return ResultString;
    }
}


Thanks,
David

8 Answers, 1 is accepted

Sort by
0
David
Top achievements
Rank 1
answered on 29 Sep 2012, 07:32 PM
Hi,

I found this approach to create multiple footer rows dynamically, but I don't quite follow the syntax. I would also rather do it in a single code block during page_init just after the columns have been bound. At that point I know all of the unique column names.

Here is my pseudo-code for a single footer row. If you can fill in the proper syntax, I'll be good to go!
WastewaterGrid Headers = WastewaterGrid.GetHeaders();
GridFooterItem footerItemAverages = new GridFooterItem(RadGrid1.MasterTableView, 0, 0);
TableCell boundTableCell;
 
foreach (DataRow headerRow in Headers.Rows)
{
    String columnName = headerRow["column_name"].ToString();
 
    boundTableCell = new TableCell();
 
    boundTableCell.identifier_based_on = parent_grid_column(columnName);
    footerItemAverages.Cells.Add(boundTableCell);
}
 
RadGrid1.MasterTableView.add_footer_item(footerItemAverages);

Thanks,
David
0
Kostadin
Telerik team
answered on 02 Oct 2012, 12:09 PM
Hello David,

This approach is not achievable in Page_Init as GridFooterItem is still not created. What I can suggest you is to use GridTemplateColumns and apply to them a custom footer template. To create a template dynamically, you must define a custom class that implements the ITemplate interface. The last section of this article shows how you can achieve that. Note that in the demonstrated approach an instance of the custom template is assign to the ItemTemplate, but the same way you could assign it to the FooterTemplate as well.

Greetings,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
David
Top achievements
Rank 1
answered on 03 Oct 2012, 06:39 PM
Hi Kostadin,

I'm beginning to create a class that inherits ITemplate. Can you help out with syntax for instantiating GridFooterItem objects? Not sure how to handle the itemIndex and setDataIndex arguments.

I guess this will involve creating one for each footer (count, average, etc.), then passing them into the template's constructor, followed by creating TextBox controls for each category.

Thanks!
David
0
David
Top achievements
Rank 1
answered on 03 Oct 2012, 11:03 PM
Hi Kostadin,

I've made a stab at it, but now my grid is empty -- including the grid bound columns.

Here is the relevant code...

column creation:
GridFooterItem footerItemCount = new GridFooterItem(RadGrid1.MasterTableView, 0, 0);
GridFooterItem footerItemMin = new GridFooterItem(RadGrid1.MasterTableView, 1, 0);
GridFooterItem footerItemMax = new GridFooterItem(RadGrid1.MasterTableView, 2, 0);
GridFooterItem footerItemAvg = new GridFooterItem(RadGrid1.MasterTableView, 3, 0);
DataTable GroupHeaders = WastewaterGrid.GetGroupHeaders();
DataTable Headers;
 
foreach (DataRow groupRow in GroupHeaders.Rows)
{
    String masterGroupName = groupRow["group_name"].ToString();
    String groupColumnHeader = groupRow["group_column_header"].ToString();
 
    Headers = WastewaterGrid.GetHeaders(masterGroupName);
 
    headerGroupColumn = new GridColumnGroup();
    headerGroupColumn.Name = masterGroupName;
    headerGroupColumn.HeaderText = groupColumnHeader;
    RadGrid1.MasterTableView.ColumnGroups.Add(headerGroupColumn);
 
    foreach (DataRow headerRow in Headers.Rows)
    {
        String groupName = headerRow["group_name"].ToString();
        String columnName = headerRow["column_name"].ToString();
        String columnHeader = headerRow["column_header"].ToString();
        String attributeType = headerRow["attribute_type"].ToString();
 
        if (!groupName.Equals(masterGroupName))
        {
            continue;
        }
 
        if (!attributeType.Contains("varchar"))
        {
            templateColumn = new GridTemplateColumn();
            templateColumn.FooterTemplate = new MyTemplate(columnName, footerItemCount, footerItemMin, footerItemMax, footerItemAvg);
            templateColumn.UniqueName = columnName;
            templateColumn.DataField = columnName;
            templateColumn.HeaderText = columnHeader;
            templateColumn.ColumnGroupName = masterGroupName;
 
            if (!attributeType.Equals("ManualEntry"))
            {
                templateColumn.ItemStyle.BackColor = disabledBackColor;
                templateColumn.ReadOnly = true;
            }
 
            RadGrid1.MasterTableView.Columns.Add(templateColumn);
        }
        else
        {
            boundColumn = new GridBoundColumn();
            boundColumn.DataField = columnName;
            boundColumn.DataField = columnName;
            boundColumn.HeaderText = columnHeader;
            boundColumn.ColumnGroupName = masterGroupName;
 
            if (!attributeType.Equals("ManualEntry"))
            {
                boundColumn.ItemStyle.BackColor = disabledBackColor;
                boundColumn.ReadOnly = true;
            }
 
            RadGrid1.MasterTableView.Columns.Add(boundColumn);
        }
    }
}

MyTemplate:
private class MyTemplate : ITemplate
{
    protected TableCell _tableCellCount;
    protected TableCell _tableCellMin;
    protected TableCell _tableCellMax;
    protected TableCell _tableCellAvg;
    protected GridFooterItem _footerItemCount;
    protected GridFooterItem _footerItemMin;
    protected GridFooterItem _footerItemMax;
    protected GridFooterItem _footerItemAvg;
    private string _columnName;
 
    public MyTemplate(String columnName, GridFooterItem footerItemCount, GridFooterItem footerItemMin, GridFooterItem footerItemMax, GridFooterItem footerItemAvg)
    {
        _columnName = columnName;
        _footerItemCount = footerItemCount;
        _footerItemMin = footerItemMin;
        _footerItemMax = footerItemMax;
        _footerItemAvg = footerItemAvg;
    }
    public void InstantiateIn(Control container)
    {
        _tableCellCount = new TableCell();
        _tableCellMin = new TableCell();
        _tableCellMax = new TableCell();
        _tableCellAvg = new TableCell();
 
        _tableCellCount.ID = "Count" + _columnName;
        _tableCellMin.ID = "Min" + _columnName;
        _tableCellMax.ID = "Max" + _columnName;
        _tableCellAvg.ID = "Avg" + _columnName;
 
        _footerItemCount.Cells.Add(_tableCellCount);
        _footerItemMin.Cells.Add(_tableCellMin);
        _footerItemMax.Cells.Add(_tableCellMax);
        _footerItemAvg.Cells.Add(_tableCellAvg);
 
        container.Controls.Add(_footerItemCount);
        container.Controls.Add(_tableCellMin);
        container.Controls.Add(_tableCellMax);
        container.Controls.Add(_tableCellAvg);
    }
}

Cheers,
David
0
Accepted
Kostadin
Telerik team
answered on 04 Oct 2012, 02:06 PM
Hi David,

I just answered your support ticket and if you would like we can continue our conversation there. Additionally I am attaching my sample here as well if somebody has to implement a similar scenario to this one.

Kind regards,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
David
Top achievements
Rank 1
answered on 04 Oct 2012, 06:24 PM
Hi Kostadin,

I believe you uploaded the files I originally attached in the support ticket.

Cheers,
David
0
Kostadin
Telerik team
answered on 08 Oct 2012, 02:19 PM
Hi David,

I attached your project instead the one which I prepared for this case. Please, excuse me for any inconvenience this might have caused you. Now it is replaced with the correct one.

Kind regards,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
David
Top achievements
Rank 1
answered on 08 Oct 2012, 10:23 PM
Hi Kostadin,

That took me where I needed to go. Thank you much!

Cheers,
David
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
David
Top achievements
Rank 1
Kostadin
Telerik team
Share this question
or