运行时数据源绑定和钻取报表数据绑定
本帖最后由 dof 于 2016-10-18 15:27 编辑主要核心使用到了LocateDataSource事件,并根据数据集的名称决定加载什么数据,核心代码:
ASP.NET WebViewer 版本源码下载:
WinForms Viewer 版本源码下载:
public partial class Index : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
return;
}
GrapeCity.ActiveReports.PageReport report = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(Server.MapPath("RdlReport1.rdlx")));
report.Document.LocateDataSource += new GrapeCity.ActiveReports.LocateDataSourceEventHandler(Document_LocateDataSource);
WebViewer1.Report = report;
}
void Document_LocateDataSource(object sender, GrapeCity.ActiveReports.LocateDataSourceEventArgs args)
{
if (args.DataSetName == "ds_Category")
{
List<Category> list_Category = new List<Category>();
list_Category.Add(new Category() { CategoryID = "1", Name = "类别1" });
list_Category.Add(new Category() { CategoryID = "2", Name = "类别2" });
list_Category.Add(new Category() { CategoryID = "3", Name = "类别3" });
list_Category.Add(new Category() { CategoryID = "4", Name = "类别4" });
args.Data = list_Category;
}else if(args.DataSetName == "ds_Product")
{
string p1 = args.Report.Parameters.CurrentValue.ToString();
List<Product> list_Product = new List<Product>();
list_Product.Add(new Product() { CategoryID = "1", ProductID = "1", Name = "产品1", Price = 20 });
list_Product.Add(new Product() { CategoryID = "1", ProductID = "2", Name = "产品2", Price = 30 });
list_Product.Add(new Product() { CategoryID = "1", ProductID = "3", Name = "产品3", Price = 23 });
list_Product.Add(new Product() { CategoryID = "1", ProductID = "4", Name = "产品4", Price = 28 });
list_Product.Add(new Product() { CategoryID = "2", ProductID = "5", Name = "产品5", Price = 20 });
list_Product.Add(new Product() { CategoryID = "2", ProductID = "6", Name = "产品6", Price = 30 });
list_Product.Add(new Product() { CategoryID = "2", ProductID = "7", Name = "产品7", Price = 23 });
list_Product.Add(new Product() { CategoryID = "2", ProductID = "8", Name = "产品8", Price = 28 });
list_Product.Add(new Product() { CategoryID = "3", ProductID = "9", Name = "产品9", Price = 20 });
list_Product.Add(new Product() { CategoryID = "3", ProductID = "10", Name = "产品10", Price = 30 });
list_Product.Add(new Product() { CategoryID = "3", ProductID = "11", Name = "产品11", Price = 23 });
list_Product.Add(new Product() { CategoryID = "3", ProductID = "12", Name = "产品12", Price = 28 });
list_Product.Add(new Product() { CategoryID = "4", ProductID = "13", Name = "产品13", Price = 20 });
list_Product.Add(new Product() { CategoryID = "4", ProductID = "14", Name = "产品14", Price = 30 });
list_Product.Add(new Product() { CategoryID = "4", ProductID = "15", Name = "产品15", Price = 23 });
list_Product.Add(new Product() { CategoryID = "4", ProductID = "16", Name = "产品16", Price = 28 });
args.Data = list_Product.Where<Product>(p => p.CategoryID == p1);
}
}
}
public class Category
{
public string CategoryID { get; set; }
public string Name { get; set; }
}
public class Product
{
public string CategoryID { get; set; }
public string ProductID{get;set;}
public string Name{get;set;}
public float Price{get;set;}
}
有html5运行时数据源绑定的demo吗? 有html5运行时数据源绑定的demo吗? ziliuxing2008 发表于 2016-10-31 10:19
有html5运行时数据源绑定的demo吗?
有的,请参考博客:http://blog.gcpowertools.com.cn/post/html5DataSourceRunTime.aspx 出现如下错误,请问如何解决? 您好,您这是数据源的绑定有问题。我给您一个关于html5运行时数据源绑定的demo您参考下!首先Htm5绑定动态数据源,需要自己重新定义Web服务,或者自己重新定义一个Web服务,然后URL绑定的时候绑定新定义的Web服务。
附件中的demo的Webform1.aspx是用的Html5动态绑定数据源
你好,前后端分离,用户在线编辑模板,保存模板,然后通过后台接口提供的所有数据,用户选择模板,预览、打印,有DEMO吗? 您好你说的用户在线编辑模板,你的项目 是B/S 项目还是C/S项目。关于动态数据源绑定你可以参考这个这一系列的demo:https://gcdn.grapecity.com.cn/forum.php?mod=viewthread&tid=48785&extra=page%3D1
集成编辑器的话你可以看着两个博客:https://gcdn.grapecity.com.cn/forum.php?mod=viewthread&tid=55211&extra=page%3D2
https://gcdn.grapecity.com.cn/forum.php?mod=viewthread&tid=52690&extra=page%3D3
页:
[1]