protected void clink_CreateDetailArea(object sender, EventArgs e)
    {
        Link self = (Link)sender;

        for (int i = 0; i < ASPxGridView1.VisibleRowCount; i += ASPxGridView1.SettingsPager.PageSize)
        {
            int       endIndex = i + ASPxGridView1.SettingsPager.PageSize;
            DataTable dt       = CreateRange(ASPxGridView1, i, endIndex);
            exportGrid.DataSource = dt;
            exportGrid.DataBind();


            DevExpress.Web.ASPxGridView.Export.Helper.GridViewLink linkdata = new DevExpress.Web.ASPxGridView.Export.Helper.GridViewLink(ASPxGridViewExporter1);
            linkdata.PrintingSystem = self.PrintingSystem;
            self.PrintingSystem.InsertPageBreak(0);


            ASPxGridViewExporter1.DataBind();


            BrickModifier skipArea = linkdata.SkipArea;
            linkdata.SkipArea = self.SkipArea;
            linkdata.AddSubreport(System.Drawing.PointF.Empty);
            linkdata.SkipArea = skipArea;
        }
    }
Beispiel #2
0
        protected void ASPxButton1_Click(object sender, EventArgs e)
        {
            if (ASPxGridView1.GroupCount == 0)
            {
                ASPxGridViewExporter1.WritePdfToResponse();
            }
            else
            {
                string         groupField  = ASPxGridView1.GetGroupedColumns()[0].FieldName;
                object[]       groupValues = FindGroupValues(ASPxGridView1);
                PrintingSystem ps          = new PrintingSystem();
                Link           clink       = new Link(ps);
                clink.CreateDetailArea += new CreateAreaEventHandler(delegate(object sender2, CreateAreaEventArgs e2)
                {
                    Link self = (Link)sender2;
                    for (int i = 0; i < groupValues.Length; i++)
                    {
                        DevExpress.Web.ASPxGridView.Export.Helper.GridViewLink linkdata = new DevExpress.Web.ASPxGridView.Export.Helper.GridViewLink(ASPxGridViewExporter1);
                        linkdata.PrintingSystemBase = self.PrintingSystem;
                        if (i > 0)
                        {
                            self.PrintingSystem.InsertPageBreak(0);
                        }
                        string filter = ASPxGridView1.FilterExpression;
                        ASPxGridView1.FilterExpression = new GroupOperator(GroupOperatorType.And,
                                                                           CriteriaOperator.Parse(filter), new BinaryOperator(groupField, groupValues[i])).ToString();
                        ASPxGridView1.ExpandAll();
                        ASPxGridViewExporter1.DataBind();

                        BrickModifier skipArea = linkdata.SkipArea;
                        linkdata.SkipArea      = self.SkipArea;
                        linkdata.AddSubreport(System.Drawing.PointF.Empty);
                        linkdata.SkipArea = skipArea;

                        ASPxGridView1.FilterExpression = filter;
                    }
                });

                clink.CreateDocument();
                ps.PageSettings.Landscape = true;
                System.IO.MemoryStream stream = new System.IO.MemoryStream();
                ps.ExportToPdf(stream);
                WriteToResponse("export", true, "pdf", stream);
                stream.Close();
            }
        }