Hi,
Summary values are not showing up in footer, please help. sample code listed below.
wbgdata1.Behaviors.CreateBehavior<SummaryRow>();
this.wbgdata1.Columns[1].Footer.Text = "Totals:";
//Summary Footer for Cartons
SummaryRowSetting BNCartonsSummary = new SummaryRowSetting(wbgdata1, "DDCARG");
BNCartonsSummary.ShowSummaryButton = false;
BNCartonsSummary.SummarySettings.Add(SummaryType.Sum);
this.wbgdata1.Behaviors.SummaryRow.ColumnSettings.Add(BNCartonsSummary);
wbgdata1.ShowFooter = true;
Thanks.
Tried adding the following code and getting the error "cannot convert from infragistics.web.ui.gridcontrols.summaryrowsetting to string". Column is defined as integer, not sure why I am getting this error.
this.wbgdata1.Behaviors.SummaryRow.ColumnSummaries.Add(BNCartonsSummary);
I am getting the same error for the code below also.
ColumnSummaryInfo BNCartonsSummary1 = new ColumnSummaryInfo();
BNCartonsSummary1.ColumnKey = "DDCARG";
BNCartonsSummary1.Summaries.Add(SummaryType.Sum);
wbgdata1.Behaviors.SummaryRow.ColumnSummaries.Add(BNCartonsSummary1);
Please help.
More details as listed below.
I am getting the error "cannot convert from infragistics.web.ui.gridcontrols.summaryrowsetting to string". Column is defined as integer, not sure why I am getting this error.
Columns are added manually as listed below:tblShipment = new DataTable("Shipment");tblShipment.Columns.Add(new DataColumn("Cartons", typeof(int)));
tc = wbgdata1.Columns["DDCARG"] as TemplateDataField;
if (tc == null)
{tc = new TemplateDataField();
tc.Key = "DDCARG";
tc.ItemTemplate = new PlaceHolderTemplate();
this.wbgdata1.Columns.Add(tc);
}
Please see the sample code that produces the error.
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 Infragistics.Web.UI.GridControls;
namespace WebApplication4
{
public partial class WebForm1 : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
GetData();
FooterValues();
public void FooterValues()
this.WebDataGrid1.Columns[0].Footer.Text = "Totals:";
WebDataGrid1.Behaviors.CreateBehavior<SummaryRow>();
ColumnSummaryInfo CartonsSummary = new ColumnSummaryInfo();
CartonsSummary.ColumnKey = "NumOfCartons";
CartonsSummary.Summaries.Add(SummaryType.Sum);
WebDataGrid1.Behaviors.SummaryRow.ColumnSummaries.Add(CartonsSummary);
SummaryRowSetting CartonsSummary1 = new SummaryRowSetting(WebDataGrid1, "Department");
CartonsSummary1.ShowSummaryButton = false;
this.WebDataGrid1.Behaviors.SummaryRow.ColumnSettings.Add(CartonsSummary1);
public void GetData()
DataTable tblShipment = new DataTable("Shipment");
tblShipment.Columns.Add(new DataColumn("NumOfCartons", typeof(int)));
UnboundField col = new UnboundField();
col.Key = "NumOfCartons";
col.Header.Text = "NumOfCartons";
this.WebDataGrid1.Columns.Add(col);
DataRow r = tblShipment.NewRow();
r["NumOfCartons"] = 30;
tblShipment.Rows.Add(r);
WebDataGrid1.DataSource = tblShipment;
//Bind the Dataset to the web grid
WebDataGrid1.DataBind();
Hello,
The unbound field is not bound to anything its type should be specified explicitly. The default type is string and should be changed to numeric type by using the DataType property.
The updated version of GetData Method:
public void GetData(){ DataTable tblShipment = new DataTable("Shipment"); tblShipment.Columns.Add(new DataColumn("NumOfCartons", typeof(int))); UnboundField col = new UnboundField(); col.Key = "NumOfCartons"; col.Header.Text = "NumOfCartons"; col.DataType = "System.Int32"; this.WebDataGrid1.Columns.Add(col); DataRow r = tblShipment.NewRow(); r["NumOfCartons"] = 30; tblShipment.Rows.Add(r); WebDataGrid1.DataSource = tblShipment; //Bind the Dataset to the web grid WebDataGrid1.DataBind();}
public void GetData(){ DataTable tblShipment = new DataTable("Shipment"); tblShipment.Columns.Add(new DataColumn("NumOfCartons", typeof(int)));
UnboundField col = new UnboundField(); col.Key = "NumOfCartons"; col.Header.Text = "NumOfCartons"; col.DataType = "System.Int32"; this.WebDataGrid1.Columns.Add(col);
DataRow r = tblShipment.NewRow(); r["NumOfCartons"] = 30; tblShipment.Rows.Add(r); WebDataGrid1.DataSource = tblShipment; //Bind the Dataset to the web grid WebDataGrid1.DataBind();}
Let me know if you need further assistance on this.
Denis,
Thanks for the update.
I have a templated column with lnk button and I am trying to get the summary for the templated column. How do change the DataType for templated column?.
Please see the sample code as listed below.
public void GetData(){ DataTable tblShipment = new DataTable("Shipment"); tblShipment.Columns.Add(new DataColumn("DDC", typeof(int))); TemplateDataField tc = WebDataGrid1.Columns["DDC"] as TemplateDataField; if (tc == null) { tc = new TemplateDataField(); tc.Key = "DDC"; tc.Header.Text = "Expected In Store"; tc.ItemTemplate = new PlaceHolderTemplate(); tc.Width = Unit.Pixel(60); this.WebDataGrid1.Columns.Add(tc); } DataRow r = tblShipment.NewRow(); r["DDC"] = 30; tblShipment.Rows.Add(r); WebDataGrid1.DataSource = tblShipment; //Bind the Dataset to the web grid WebDataGrid1.DataBind();}
private class PlaceHolderTemplate : ITemplate {
#region ITemplate Members
public void InstantiateIn(Control container) { GridRecordItem gri = (GridRecordItem)((Infragistics.Web.UI.TemplateContainer)(container)).Item;
switch (gri.Column.Key) { case "DDC": LinkButton lnk = new LinkButton(); lnk.ID = "LinkButton1"; lnk.Attributes.Add("onClick", "ClientClick();"); container.Controls.Add(lnk); break; } } } protected void WebDataGrid1_InitializeRow(object sender, Infragistics.Web.UI.GridControls.RowEventArgs e) { LinkButton lnk; lnk = (LinkButton)e.Row.Items.FindItemByKey("DDC").FindControl("LinkButton1"); if (lnk != null) { lnk.Text = tblShipment.Rows[e.Row.Index][0].ToString(); lnk.Attributes["onclick"] = "BLOCKED SCRIPTbuttonClick('" + lnk.Text + "');"; lnk.Attributes["onmouseover"] = "this.style.color=\'#ff0000\'"; lnk.Attributes["onmouseout"] = "this.style.color=\'#000000\'"; lnk.ForeColor = Color.Black; lnk.Click += new EventHandler(this.lnk_Click);
} }
Thanks for your help.
The TemplateDataField has property Type.
Let me know if I may be of further assistance.
I tried to use type property, but not successful. Please send me the sample code demonstrating type property with TemplateDataField.
Thank you for reporting this.
I have asked our engineering staff to examine this further. To ensure that it will receive attention, I have logged this behavior in our internal tracking system with a Development ID of 236746. A support case is created on your behalf with number CAS-183509-S8H5L0, so that you can be notified when the bug is fixed. You can find your active cases under Account - Support Activity in our website. Select your ticket and go to Development Issues tab to view the status of related bugs.
summary value is getting doubled for the regular unbound column, please review the sample code attached.
We have a forum post about calculating summary for template field, you can take a look at it.
Also, is it possible to remove the caption sum = ?.
Thank you for the sample code. I am able o get the summary of the template column using your code, but I noticed that summary value is getting doubled for the unbound column. Please review the sample code and advise.