We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Adjust colums to export to PDF

Hi,

 Is posible adjust the width of ggc or pdf to view all columns displayed in one page, in my grid the last colums showed in other page. Or change the font size etc...
 I change the PdfPageOrientation to Landscape with the same result.

Thanks


6 Replies

PM Piruthiviraj Malaimelraj Syncfusion Team June 21, 2016 01:45 PM UTC

  
Hi Ruben, 

Thank you for using Syncfusion products. 

Sample link:  
Query 
Solution 
Is posible adjust the width of ggc or pdf to view all columns displayed in one page, in my grid the last colums showed in other page. Or change the font size etc... 
We don’t have direct support to adjust the page width while exporting  the grid to PDF. In order to resize the column width of the grid while exporting the PDF, Exporting event can be used. Please make use of below code. 

Suggestion1: 
void pdfConvertor_Exporting(object sender, PDFExportingEventArgs e) 
{ 
          e.PdfDocument.PageSettings.Width = this.gridGroupingControl1.TableModel.ColWidths.GetTotal(0, this.gridGroupingControl1.TableModel.ColCount); 
} 

Suggestion 2: 
void pdfConvertor_Exporting(object sender, PDFExportingEventArgs e) 
{  
     e.PdfDocument.PageSettings.Orientation = Syncfusion.Pdf.PdfPageOrientation.Landscape;  
} 

Sample link: 
 
Regards, 
Piruthiviraj 



RU Ruben June 23, 2016 12:02 PM UTC

Thanks, works fine.
One question in my ggc when grouped for city, country .... in a customers table, always show 0 items when have results I can expand and see the results, any idea?
In others grids show the items.

Thanks

Attachment: e_ca248a77.rar


PM Piruthiviraj Malaimelraj Syncfusion Team June 24, 2016 12:40 PM UTC

Hi Ruben, 
 
Thank you for your update. 
 
We had analyzed your reported scenario. Unfortunately we could not able to reproduce your reported scenario. Here we have provided the sample based on your scenario.  We need some more details about your issue. Could you please provide us with the following details, 
1.       Can you please ensure whether the reported issue is reproducing in the attached sample? 
2.       Did you added any summary customization in your application? 
 
 
 
Please have a look on to the below attached sample. Please let us know if we missed anything other than your customization. 
 
Sample link 

Regards, 
Piruthiviraj 



RU Ruben June 27, 2016 06:54 AM UTC

Hi Piruthiviraj,

 I have a summary customization it´s imcompatible?

Thanks.


RU Ruben June 27, 2016 07:38 AM UTC

I comment out and the result it´s the same, paste my code.

private void FormConsumos_Load(object sender, EventArgs e)
        {
            //  GridSettings();
            //ClientesCN clientesCN = new ClientesCN();
            //List<Cliente> clientes = clientesCN.ClientesconVentas();

            List<Clientes1> clientes = (from c in datos.Cliente
                                        join f in datos.FacturaCliente
                                        on c.NumCliente equals f.Cliente
                                        join z in datos.Zona
                                    on c.Codzona equals z.Codzona
                                        select new Clientes1
                                        {
                                            NumCliente = c.NumCliente,
                                            Nombre = c.Nombre,
                                            Telefono = c.Telefono,
                                            Movil = c.Movil,
                                            Poblacion = c.Poblacion,
                                            Provincia = c.Provincia,
                                            Zona = z.Descripcion,
                                            Comercial = c.Comercial,
                                            Direccion = c.Direccion
                                        }
                               ).Distinct().ToList();


            //Localizacion loc = new Localizacion();
            //loc.getstring(true, true, true, true);
            //LocalizationProvider.Provider = loc;


            int totalclientes = clientes.Count();
           // grid.TableOptions.ColumnsMaxLengthStrategy = GridColumnsMaxLengthStrategy.FirstNRecords;
            IEnumerable clienteejem = clientes.Take(10);
            IEnumerable orderDetailSamples = (from p in datos.Vista_Consumo_Clientes select p).Take(10);

            PassThroughGroupingResult ListadoFacturas = new PassThroughGroupingResult(
                    "Clientes",
                    clientes,
                    typeof(Clientes1),
                    totalclientes,
                    clienteejem,
                    new UpdateHelper()
                    );

            PassThroughGroupingResult orderDetailResults = new PassThroughGroupingResult(
                    "Pruebas",
                    new NestedQueryResultsDelegate(this.GetOrderDetailForOrder),
                    typeof(Pruebas),
                    orderDetailSamples
                    );

            grid.SourceListSet.Add("Clientes", ListadoFacturas);
            grid.SourceListSet.Add("Articulos", orderDetailResults);

            grid.DataSource = ListadoFacturas;
            grid.ShowGroupDropArea = true;
            grid.AllowProportionalColumnSizing = true;

            grid.TableDescriptor.Relations.Clear();
            GridRelationDescriptor orders = new GridRelationDescriptor("Articulos");
            orders.RelationKind = RelationKind.RelatedMasterDetails;
            orders.RelationKeys.Add("NumCliente", "NumCliente");
            orders.ChildTableName = "Articulos";
            orders.ChildTableDescriptor.Relations.Clear();
            grid.TableDescriptor.AllowNew = false;
            grid.TableDescriptor.AllowEdit = false;
            grid.TableDescriptor.AllowRemove = false;

            //grid.TableDescriptor.Columns["NumCliente"].HeaderText = "Nº Cliente";
            //grid.TableDescriptor.Columns["Nombre"].HeaderText = "Nombre";
            //grid.TableDescriptor.Columns["Poblacion"].HeaderText = "Poblacion";
            //grid.TableDescriptor.Columns["Provincia"].HeaderText = "Provincia";
            //grid.TableDescriptor.Columns["Telefono"].HeaderText = "Teléfono";
            //grid.TableDescriptor.Columns["Movil"].HeaderText = "Móvil";
            //grid.TableDescriptor.Columns["Zona"].HeaderText = "Zona";

            grid.TableDescriptor.Relations.Add(orders);

            grid.TopLevelGroupOptions.ShowFilterBar = true;
            grid.GridGroupDropArea.DragColumnHeaderText = "Arrastre el encabezado para agrupar.";
            grid.NestedTableGroupOptions.ShowFilterBar = true;
            grid.ChildGroupOptions.ShowFilterBar = true;

            //Enable the filter for each columns 
            grid.TableDescriptor.Name = "Clientes";
            for (int i = 0; i < grid.TableDescriptor.Columns.Count; i++)
                grid.TableDescriptor.Columns[i].AllowFilter = true;

            this.grid.TableOptions.ListBoxSelectionMode = SelectionMode.MultiExtended;

            this.grid.UseDefaultsForFasterDrawing = true;
            this.grid.TopLevelGroupOptions.ShowFilterBar = true;
            this.grid.ChildGroupOptions.ShowFilterBar = true;


            //GridSummaryColumnDescriptor scd = new GridSummaryColumnDescriptor("Sum", SummaryType.Int32Aggregate, "Cantidad", "{Sum:#}");
            //GridSummaryRowDescriptor srd = new GridSummaryRowDescriptor("Sum", "Total", scd);
            //srd.Appearance.AnyCell.HorizontalAlignment = GridHorizontalAlignment.Right;
            //srd.Appearance.AnyCell.BackColor = SystemColors.Info;
            //grid.GetTableDescriptor("Articulos").SummaryRows.Add(srd);
            //grid.GetTableDescriptor("Articulos").AllowEdit = false;
            //grid.GetTableDescriptor("Articulos").AllowNew = false;
            //grid.GetTableDescriptor("Articulos").AllowRemove = false;
            //grid.GetTableDescriptor("Articulos").Columns[0].Width = 150;
            //grid.GetTableDescriptor("Articulos").Columns[1].Width = 370;
            //grid.GetTableDescriptor("Articulos").Columns[2].Width = 80;
            //grid.GetTableDescriptor("Articulos").Columns[3].Width = 80;

            //GridTableDescriptor gtd = grid.GetTableDescriptor("Articulos");


            //GridConditionalFormatDescriptor Descriptor1 = new GridConditionalFormatDescriptor();
            //Descriptor1.Appearance.AnyRecordFieldCell.TextColor = System.Drawing.Color.Red;
            //Descriptor1.Expression = "[Cantidad] < 0";
            //gtd.ConditionalFormats.Add(Descriptor1);

            ////GridSummaryColumnDescriptor prizeAvgSummary = new GridSummaryColumnDescriptor(
            ////    "Precio",
            ////    SummaryType.Custom,
            ////    "UnitPrice",
            ////    "{PrizeAvg:#.##}"
            ////    );
            ////orderDetail.ChildTableDescriptor.SummaryRows.Add(
            ////    new GridSummaryRowDescriptor("Row 1", prizeAvgSummary)
            ////    );
            ////orderDetail.ChildTableDescriptor.TopLevelGroupOptions.CaptionText =
            ////    "{TableName}: {RecordCount} Items, Average UnitPrice is {Row 1.PrizeAvgSummary}";
            ////orders.ChildTableDescriptor.Relations.Add(orderDetail);

            ////GridTableDescriptor tabd = grid.GetTableDescriptor("ArticuloFacturaCliente");

            //grid.AddGroupDropArea("Clientes");

            //grid.AddGroupDropArea("Articulos");


            filter.WireGrid(grid);
        }

        public IEnumerable GetOrdersForCustomer(object[] keys, out object totals)
        {
            var orderQuery =
                from p in datos.FacturaCliente
                where p.Cliente.Equals(keys[0])
                select p
                ;

            totals = orderQuery.Count();
            return orderQuery;
        }

        public IEnumerable GetOrderDetailForOrder(object[] keys, out object totals)
        {
            var precios = from f in datos.Vista_Consumo_Clientes
                          where f.NumCliente == keys[0].ToString()
                          orderby f.Cantidad descending
                          select new Pruebas
                          {
                              Referencia = f.Referencia,
                              Descripcion = f.Descripcion,
                              Cantidad = Convert.ToDecimal(f.Cantidad),
                              Precio = Convert.ToDecimal(f.precio)
                          }
                          ;

            totals = precios.Count();
            return precios;
        }


PM Piruthiviraj Malaimelraj Syncfusion Team June 28, 2016 02:22 PM UTC

Hi Ruben, 

Thank you for your update. 

We had analyzed your scenario, but still we were not able to reproduce the issue. We consider that the issue can be occurred in way of using datasource to the control in your application or the records did not bind properly to data source.  Can you please ensure whether the reported issue is reproducing in the attached sample? . please modify the attached sample with your simple source you used. It would be more helpful for us to provide the exact solution at the earliest. 
 
Sample link 
 
Regards, 
Piruthiviraj 


Loader.
Up arrow icon