¿Quieres registrarte?

Imprimir datos desde un DataGrid en Flex

Por: alfathenus
30 de Marzo del 2009
4,125 visitas

Este es un tip que a los que trabajamos con Flex, nos piden mucho: cómo imprimir datos desde un DataGrid, AdvancedDataGrid u OLAPDataGrid.

Flex nos provee clases específicas para imprimir los datos mostrados en esos componentes, estas clases son PrintDataGrid, PrintAdvancedDataGrid y PrintOLAPDataGrid. Con ellas podremos paginar los datos e imprimirlos de manera correcta.

Aquí les dejo un útil para que puedan imprimir agregándoles un encabezado y pie de pagina, un titulo, la cantidad de filas y la numeración de cada hoja. El componente cuenta con 2 clases, la clase principal q imprime y una clase de configuración

TabularPrint.as

Código :

package com.alozada.utils.print
{
   import flash.errors.IllegalOperationError;
   
   import mx.containers.HBox;
   import mx.containers.VBox;
   import mx.controls.AdvancedDataGrid;
   import mx.controls.DataGrid;
   import mx.controls.Label;
   import mx.controls.OLAPDataGrid;
   import mx.controls.Spacer;
   import mx.core.Application;
   import mx.core.UIComponent;
   import mx.printing.FlexPrintJob;
   import mx.printing.PrintAdvancedDataGrid;
   import mx.printing.PrintDataGrid;
   import mx.printing.PrintOLAPDataGrid;
   import mx.resources.ResourceManager;
   
   /**
    *
    * Author: Andrés Lozada Mosto
    * Version: 1.0
    * Fecha release: 25/03/2009
    * Contacto: alfathenus@gmail.com
    * Clase que imprime datos de forma tabulada
    * 
    * @example
    * <code>
    * var options:TabularPrintOptions = new TabularPrintOptions();
    * options.viewPageNumber = true;
    * options.viewSumarize = true;
    * TabularPrint.fromDataGrid(myDataGrid, options);
    * </code>
    * 
    * Lista de funciones
    * <list>
    *  fromDataGrid:             Imprime los datos de un Datagrid
    *  fromAdvancedDataGrid:      Imprime los datos de un AdvancedDatagrid
    *  fromOLAPDatagrid:          Imprime los datos de un OLAPDatagrid
    *  print:                  Imprime los datos de un Datagrid, AdvancedDataGrid u OLAPDataGrid
    * </list>
    * 
    */
   public class TabularPrint
   {
      
      public function TabularPrint()
      {
         throw new IllegalOperationError("TabularPrint class is static. Don't instace");
      }
      
      /**
       * 
       * Imprime los datos de un Datagrid
       * 
       * @param grid         Refernecia al DataGrid
       * @param options      Opciones de impresion
       * 
       * @return True si se pudo imprimir, False si no se pudo imprimir o se cancelo la impresion
       * 
       */
      static public function fromDataGrid(grid:DataGrid, options:TabularPrintOptions):Boolean
      {
         return doPrint(grid, PrintDataGrid, options);
      }
      
      /**
       * 
       * Imprime los datos de un AdvancedDatagrid
       * 
       * @param grid         Refernecia al AdvancedDataGrid
       * @param options      Opciones de impresion
       * 
       * @return True si se pudo imprimir, False si no se pudo imprimir o se cancelo la impresion
       * 
       */
      static public function fromAdvancedDataGrid(grid:AdvancedDataGrid, options:TabularPrintOptions):Boolean
      {
         return doPrint(grid, PrintAdvancedDataGrid, options);
      }
      
      /**
       * 
       * Imprime los datos de un OLAPDatagrid
       * 
       * @param grid         Refernecia al OLApDataGrid
       * @param options      Opciones de impresion
       * 
       * @return True si se pudo imprimir, False si no se pudo imprimir o se cancelo la impresion
       * 
       */
      static public function fromOLAPDatagrid(grid:OLAPDataGrid, options:TabularPrintOptions):Boolean
      {
         return doPrint(grid, PrintOLAPDataGrid, options);
      }
      
      /**
       * 
       * Imprime los datos de un Datagrid, AdvancedDataGrid u OLAPDataGrid
       * 
       * @param grid         Refernecia al componente
       * @param options      Opciones de impresion
       * 
       * @return True si se pudo imprimir, False si no se pudo imprimir o se cancelo la impresion
       * 
       */
      static public function print(grid:*, options:TabularPrintOptions = null):Boolean
      {
         if ( options == null )
            options = new TabularPrintOptions();
            
         if ( grid is DataGrid )
         {
            return fromDataGrid(grid, options);
         }
         else if ( grid is AdvancedDataGrid )
         {
            return fromAdvancedDataGrid(grid, options);
         }
         else if ( grid is OLAPDataGrid )
         {
            return fromOLAPDatagrid(grid, options);
         }
         
         return false;
      }
      
      //-----------------------------------------
      // Private methods
      //-----------------------------------------
      static protected function createPage(grid:*, options:TabularPrintOptions):VBox
      {
         grid.id = "grid";
         grid.name = "grid";
         (grid as UIComponent).percentWidth = 100;
         (grid as UIComponent).percentHeight = 100;
         
         var vbox:VBox = new VBox();
         vbox.percentWidth = 100;
         
         //agrego header
         if (options.headerViewInAllPages != null )
         {
            options.headerViewInAllPages.name = "header";
            options.headerViewInAllPages.percentWidth = 100;
            vbox.addChild(options.headerViewInAllPages);
         }
         
         //agrego header en primer hoja
         if (options.headerViewInFirstPage != null )
         {
            options.headerViewInFirstPage.name = "headerFirst";
            options.headerViewInFirstPage.percentWidth = 100;
            vbox.addChild(options.headerViewInFirstPage);
         }
         
         //agrego data
         vbox.addChild(grid);
         vbox.setStyle("backgroundColor", 0xFFFFFF);
         
         // agrego sumarizador
         if (options.viewSumarize )
         {
            var hbox:HBox = new HBox();
            hbox.percentWidth = 100;
            hbox.name = "hbox";
            hbox.id = "sumarize";
            hbox.name = "sumarize";
            var spacer:Spacer = new Spacer();
            spacer.percentWidth = 100;
            hbox.addChild(spacer);
            var l:Label = new Label();
            if (options.sumarizelabelKeyInternationalize != "" && options.sumarizeLabelDefault != "")
               l.text = ResourceManager.getInstance().getString(options.propertiesFile, options.sumarizelabelKeyInternationalize)
            if (l.text == "")
               l.text = options.sumarizeLabelDefault;
            l.text = l.text + grid.dataProvider.length;
            hbox.addChild(l);
            hbox.visible = false;
            hbox.includeInLayout = false;
            vbox.addChild(hbox);
         }
         
         //agrego footer
         if (options.footerViewInAllPages != null )
         {
            options.footerViewInAllPages.name = "header";
            options.footerViewInAllPages.percentWidth = 100;
            vbox.addChild(options.footerViewInAllPages);
         }
         
         //agrego numero de pagina
         if ( options.viewPageNumber )
         {
            var hbox2:HBox = new HBox();
            hbox2.percentWidth = 100;
            hbox2.name = "hbox";
            var spacer2:Spacer = new Spacer();
            spacer2.percentWidth = 100;
            hbox2.addChild(spacer2);
            var label:Label = new Label();
            if (options.pageNumberLabelKeyInternationalize != "" && options.propertiesFile != "")
               label.text = ResourceManager.getInstance().getString(options.propertiesFile, options.pageNumberLabelKeyInternationalize)
            if (label.text == "")
               label.text = options.pageNumberLabelDefault;
            label.id = "page";
            label.name = "page";
            hbox2.addChild(label);
            vbox.addChild(hbox2);
         }
         
         return vbox;
      }
      
      static protected function doPrint(grid:*, clase:Class, options:TabularPrintOptions):Boolean
      {
         if ( grid == null || grid.dataProvider == null ||
         clase == null ||  
         grid.dataProvider.hasOwnProperty("length") == false || grid.dataProvider.length == 0)
         {
            return false;
         }
         
         if ( options == null )
            options = new TabularPrintOptions();
         
         var printView:* = new clase();
         printView.dataProvider = grid.dataProvider;
         
         var vbox:VBox = createPage(printView, options);
         
         return doPrintAction(vbox, options);
      }
      
      static protected function doPrintAction(view:*, options:TabularPrintOptions):Boolean
      {
         var printView:* = (view as UIComponent).getChildByName("grid");
         var page:Label;
         var pageText:String;
         var pageCount:int = 0;
         if ( options.viewPageNumber )
         {
            page = ((view as UIComponent).getChildByName("hbox") as HBox).getChildByName("page") as Label;
            pageText = page.text;
         }
         if ( printView == null )
            return false;;
         
         var printJob:FlexPrintJob = new FlexPrintJob();
          if (printJob.start()) {
             
             Application.application.addChild(view);
             view.width=printJob.pageWidth;
                view.height=printJob.pageHeight;
             
             while(true)
             {
                pageCount++;
                if ( page )
                {
                   page.text = pageText + pageCount.toString();
                }
                
                if(printView.validNextPage)
                    {
                       printJob.addObject(view);
                  printView.nextPage();
                    }
                    else
                    {
                       if (options.viewSumarize )
                  {
                     var sum:HBox = ((view as UIComponent).getChildByName("sumarize") as HBox);
                     if (sum)
                     {
                        sum.visible = true;
                        sum.includeInLayout = true;
                        sum.validateNow();
                     }
                  }
                       printJob.addObject(view);
                       break;
                    }
                    
                    if ( pageCount > 0 )
                    {
                       var headerFirst:* = (view as UIComponent).getChildByName("headerFirst");
                       if ( headerFirst != null )
                       {
                          headerFirst.visible = false;
                          headerFirst.includeInLayout = false;
                       }
                    }
             }
             
             Application.application.removeChild(view);
             printJob.send();
             return true;
          }
          return false;
      }
   }
}


TabularPrintOptions.as

Código :

package com.alozada.utils.print
{
   import mx.core.UIComponent;
   
   public class TabularPrintOptions
   {
      /**
       * Componente header q se agrega en la impresion solo en la primer pagina
       */
      public var headerViewInFirstPage:UIComponent;
      /**
       * Componente header q se agrega en la impresion en todas las paginas
       */
      public var footerViewInAllPages:UIComponent;
      /**
       * Componente footer q se agrega en la impresion en todas las paginas
       */
      public var headerViewInAllPages:UIComponent;
      
      /**
       * Nombre del archivo properties de donde se sacan las claves de internacionalizacion
       */
      public var propertiesFile:String;
      
      /**
       * Indica si se muestra o no la cantidad de filas impresas
       */
      public var viewSumarize:Boolean = true;
      /**
       * Texto por default del indicador de cantidad de filas
       */
      public var sumarizeLabelDefault:String = "Total rows: ";
      /**
       * Clave de internacionalizacion del indicador de cantidad de filas
       */
      public var sumarizelabelKeyInternationalize:String;
      
      /**
       * Indica si se muestra o no el numero de paginas
       */
      public var viewPageNumber:Boolean = true;
      /**
       * Texto por default de la cantidad de paginas
       */
      public var pageNumberLabelDefault:String = "Page: ";
      /**
       * Clave de internacionalizacion de la cantidad de paginas
       */
      public var pageNumberLabelKeyInternationalize:String;   
      
      public function TabularPrintOptions()
      {
      }
      
   }
}


Y su uso es muy sencillo

Código :

TabularPrint.fromDataGrid(myDataGrid)


Bueno, espero q les sirva.

Saludos!

Enviar a twitter Enviar a facebook


También te interesa


Etiquetas flex actionscript_3

Comentarios | Enviar un comentario
Buen tip. Gracias por compartir las clases (y)
Por: Zguillez
Espectacular tips!!, aprovecho para preguntarte donde puedo aprender flex desde cero, tengo alguna idea pero....., lo que mas me interesa es usar flex / flash / php / mysql, juntos para poder usar el datagrid de flex, donde puedo conseguir estos materiales, gracias!!!
Pongan mas tips de estos espectaculares de FLEX!!!!
Por: arieljbon
Gente, aca agrege una mejora para q tome los renderers, label function y demas y asi imprimir los datos tal como se ven

[/as]package com.alfathenus.print
{
import flash.errors.IllegalOperationError;

import mx.containers.HBox;
import mx.containers.VBox;
import mx.controls.AdvancedDataGrid;
import mx.controls.DataGrid;
import mx.controls.Label;
import mx.controls.OLAPDataGrid;
import mx.controls.Spacer;
import mx.core.Application;
import mx.core.UIComponent;
import mx.printing.FlexPrintJob;
import mx.printing.PrintAdvancedDataGrid;
import mx.printing.PrintDataGrid;
import mx.printing.PrintOLAPDataGrid;
import mx.resources.ResourceManager;

/**
*
* Author: Andrés Lozada Mosto
* Version: 1.0
* Fecha release: 25/03/2009
* Contacto: alfathenus@gmail.com
* Clase que imprime datos de forma tabulada
*
* @example
* <code>
* var options:TabularPrintOptions = new TabularPrintOptions();
* options.viewPageNumber = true;
* options.viewSumarize = true;
* TabularPrint.fromDataGrid(myDataGrid, options);
* </code>
*
* Lista de funciones
* <list>
* fromDataGrid: Imprime los datos de un Datagrid
* fromAdvancedDataGrid: Imprime los datos de un AdvancedDatagrid
* fromOLAPDatagrid: Imprime los datos de un OLAPDatagrid
* print: Imprime los datos de un Datagrid, AdvancedDataGrid u OLAPDataGrid
* </list>
*
*/
public class TabularPrint
{

public function TabularPrint()
{
throw new IllegalOperationError("TabularPrint class is static. Don't instace");
}

/**
*
* Imprime los datos de un Datagrid
*
* @param grid Refernecia al DataGrid
* @param options Opciones de impresion
*
* @return True si se pudo imprimir, False si no se pudo imprimir o se cancelo la impresion
*
*/
static public function fromDataGrid(grid:DataGrid, options:TabularPrintOptions):Boolean
{
return doPrint(grid, PrintDataGrid, options);
}

/**
*
* Imprime los datos de un AdvancedDatagrid
*
* @param grid Refernecia al AdvancedDataGrid
* @param options Opciones de impresion
*
* @return True si se pudo imprimir, False si no se pudo imprimir o se cancelo la impresion
*
*/
static public function fromAdvancedDataGrid(grid:AdvancedDataGrid, options:TabularPrintOptions):Boolean
{
return doPrint(grid, PrintAdvancedDataGrid, options);
}

/**
*
* Imprime los datos de un OLAPDatagrid
*
* @param grid Refernecia al OLApDataGrid
* @param options Opciones de impresion
*
* @return True si se pudo imprimir, False si no se pudo imprimir o se cancelo la impresion
*
*/
static public function fromOLAPDatagrid(grid:OLAPDataGrid, options:TabularPrintOptions):Boolean
{
return doPrint(grid, PrintOLAPDataGrid, options);
}

/**
*
* Imprime los datos de un Datagrid, AdvancedDataGrid u OLAPDataGrid
*
* @param grid Refernecia al componente
* @param options Opciones de impresion
*
* @return True si se pudo imprimir, False si no se pudo imprimir o se cancelo la impresion
*
*/
static public function print(grid:*, options:TabularPrintOptions = null):Boolean
{
if ( options == null )
options = new TabularPrintOptions();

if ( grid is DataGrid )
{
return fromDataGrid(grid, options);
}
else if ( grid is AdvancedDataGrid )
{
return fromAdvancedDataGrid(grid, options);
}
else if ( grid is OLAPDataGrid )
{
return fromOLAPDatagrid(grid, options);
}

return false;
}

//-----------------------------------------
// Private methods
//-----------------------------------------
static protected function createPage(grid:*, options:TabularPrintOptions):VBox
{
grid.id = "grid";
grid.name = "grid";
(grid as UIComponent).percentWidth = 100;
(grid as UIComponent).percentHeight = 100;

var vbox:VBox = new VBox();
vbox.percentWidth = 100;

//agrego header
if (options.headerViewInAllPages != null )
{
options.headerViewInAllPages.name = "header";
options.headerViewInAllPages.percentWidth = 100;
vbox.addChild(options.headerViewInAllPages);
}

//agrego header en primer hoja
if (options.headerViewInFirstPage != null )
{
options.headerViewInFirstPage.name = "headerFirst";
options.headerViewInFirstPage.percentWidth = 100;
vbox.addChild(options.headerViewInFirstPage);
}

//agrego data
vbox.addChild(grid);
vbox.setStyle("backgroundColor", 0xFFFFFF);

// agrego sumarizador
if (options.viewSumarize )
{
var hbox:HBox = new HBox();
hbox.percentWidth = 100;
hbox.name = "hbox";
hbox.id = "sumarize";
hbox.name = "sumarize";
var spacer:Spacer = new Spacer();
spacer.percentWidth = 100;
hbox.addChild(spacer);
var l:Label = new Label();
if (options.sumarizelabelKeyInternationalize != "" && options.sumarizeLabelDefault != "")
l.text = ResourceManager.getInstance().getString(options.propertiesFile, options.sumarizelabelKeyInternationalize)
if (l.text == "")
l.text = options.sumarizeLabelDefault;
l.text = l.text + grid.dataProvider.length;
hbox.addChild(l);
hbox.visible = false;
hbox.includeInLayout = false;
vbox.addChild(hbox);
}

//agrego footer
if (options.footerViewInAllPages != null )
{
options.footerViewInAllPages.name = "header";
options.footerViewInAllPages.percentWidth = 100;
vbox.addChild(options.footerViewInAllPages);
}

//agrego numero de pagina
if ( options.viewPageNumber )
{
var hbox2:HBox = new HBox();
hbox2.percentWidth = 100;
hbox2.name = "hbox";
var spacer2:Spacer = new Spacer();
spacer2.percentWidth = 100;
hbox2.addChild(spacer2);
var label:Label = new Label();
if (options.pageNumberLabelKeyInternationalize != "" && options.propertiesFile != "")
label.text = ResourceManager.getInstance().getString(options.propertiesFile, options.pageNumberLabelKeyInternationalize)
if (label.text == "")
label.text = options.pageNumberLabelDefault;
label.id = "page";
label.name = "page";
hbox2.addChild(label);
vbox.addChild(hbox2);
}

return vbox;
}

static protected function doPrint(grid:*, clase:Class, options:TabularPrintOptions):Boolean
{
if ( grid == null || grid.dataProvider == null ||
clase == null ||
grid.dataProvider.hasOwnProperty("length") == false || grid.dataProvider.length == 0)
{
return false;
}

if ( options == null )
options = new TabularPrintOptions();

var printView:* = new clase();
printView.columns = grid.columns;

formatView(printView, grid);

if ((printView as Object).hasOwnProperty("groupedColumns") && Object(grid).hasOwnProperty("groupedColumns"))
Object(printView).groupedColumns = Object(grid).groupedColumns;

printView.dataProvider = grid.dataProvider;

var vbox:VBox = createPage(printView, options);

return doPrintAction(vbox, options);
}

static protected function formatView(view:*, original:*):void
{
var propDataGrid:Array = ["columnWidth","dataTipField","dataTipFunction","itemEditorInstance","itemRenderer","nullItemRenderer","data",
"headerHeight","headerRenderer","headerWordWrap"];
var propAdDataGrid:Array = ["columnWidth", "data", "dataTipField",
"dataTipFunction","groupedColumns","groupIconFunction","groupItemRenderer","groupLabelFunction",
"groupRowHeight","headerHeight","headerRenderer","headerWordWrap","hierarchicalCollectionView",
"itemRenderer","labelFunction","rowHeight","showHeaders","showInAutomationHierarchy","variableRowHeight"];
var propOlap:Array = ["defaultCellString", "headerRendererProviders", "itemRendererProviders"];

var propToFormat:Array = [];

if ( view is Array )
{
propToFormat = propDataGrid;
}
else if (view is AdvancedDataGrid )
{
propToFormat = propAdDataGrid;
if ( view is OLAPDataGrid)
{
propToFormat = propToFormat.concat(propOlap);
}
}

for ( var i:int = 0; i < propToFormat.length; i++)
{
if( Object(view).hasOwnProperty(propToFormat[i]) && Object(original).hasOwnProperty(propToFormat[i]))
{
Object(view)[propToFormat[i]] = original[propToFormat[i]];
}
}
}

static protected function doPrintAction(view:*, options:TabularPrintOptions):Boolean
{
var printView:* = (view as UIComponent).getChildByName("grid");
var page:Label;
var pageText:String;
var pageCount:int = 0;
if ( options.viewPageNumber )
{
page = ((view as UIComponent).getChildByName("hbox") as HBox).getChildByName("page") as Label;
pageText = page.text;
}
if ( printView == null )
return false;;

var printJob:FlexPrintJob = new FlexPrintJob();
if (printJob.start()) {

Application.application.addChild(view);
view.width=printJob.pageWidth;
view.height=printJob.pageHeight;

while(true)
{
pageCount++;
if ( page )
{
page.text = pageText + pageCount.toString();
}

if(printView.validNextPage)
{
printJob.addObject(view);
printView.nextPage();
}
else
{
if (options.viewSumarize )
{
var sum:HBox = ((view as UIComponent).getChildByName("sumarize") as HBox);
if (sum)
{
sum.visible = true;
sum.includeInLayout = true;
sum.validateNow();
}
}
printJob.addObject(view);
break;
}

if ( pageCount > 0 )
{
var headerFirst:* = (view as UIComponent).getChildByName("headerFirst");
if ( headerFirst != null )
{
headerFirst.visible = false;
headerFirst.includeInLayout = false;
}
}
}

Application.application.removeChild(view);
printJob.send();
return true;
}
return false;
}
}
}[/as]

Avisen si ven algun error o si ven q se puede mejorar algo tanto en cuanto a codigo o funcionalidad

Saludos!
Por: alfathenus
uff espero q algun admin arregle el tag de bbcode q escribi mal y no puedo editar...

Saludos!
Por: alfathenus
alfathenus: Soy nuevo en Flex y por eso te pregunto algo que seguro es obvio, mira, hice los dos archivos .as y los meti en src... com etc... Despues como los llamo desde el Mxml? tengo una grilla con un boton, como le mando la accion de que imprima? Gracias y disculpa mi pregunta pero soy nuevo.
Por: xchacalx
hola

Fijate q en el codigo de la clase hay un ejemplo.

Simplemente en el mxml create una funcion

Código :

private function imprimir():void
{
       TabularPrint.fromDataGrid(myDataGrid);
}


Y listo, a esa funcion la llamas desde un boton o desde donde vos queiras del mxml


Saludos!
Por: alfathenus
Execelte Tips... Resolvio mi problema de imprimir my_datagrid
Por: Elias-blog
que honda con esta instruccion
tengo que crear este directorio?

package com.alozada.utils.print
Por: marcos-blog
hola marcos

Si tenes q crear com/alozada/utils/print

sino, podes cambiar el package y crear la ruta del directorio q necesites...


Recorda q el packague debe coincidir con la ruta de carpetas en donde esta el archivo .as
Por: alfathenus
ya cree los 2 archivos y lo guarde en marcos.compilar.src.print
hice la funcion em mi mxml principal
y me manda el error: El acceso de propiedad indefinida TabularPrint.
debo import el paquete o include el archivo.as????
Por: Marcos-blog
Mmm y si dejas los nombres de los paquetes y las clases tal como deberian? Porque internamente se importan y se utilizan las demas clases... sino vas a tener q cambiar todas las referencias internas....

Saludos!
Por: alfathenus
ya lo corregi! gracias! ahora me manda el siguiente error:
"Incorrect number of arguments.Expected 2" Para TabularPrint.fromDataGrid(dataGrid);
Por: marcos-blog
Mmmmm

Dice q estas llamando al a funcion correctamente.... el mensaje de error es claro, el ejemplo q acompaña a la clase tambien esta claro y es tal lo q intentas hacer...... :?
Por: alfathenus
Hola.

Aplique el ejemplo pero me manda error...

'A file foundo in a source-path must have the same package structure ", as the definition's package, 'con.alozada.utils.print''
Por: hIUG
mmm a algun archivo lo colocaste en algun directorio diferente a lo q se especifica en el paquete de la clase.... fijate q el path de directorios sea igual al del paquete en donde se declara la clase....

Una clase en donde se la define en el siguiente paquete

Código :

package com.bla1.bla_mas_mas

Debe estar en un path de directorios asi

Código :

com/bla1/bla_mas_mas

teniendo como root, el directorio base de donde del proyecto (o de la carpeta de recursos/archivos, q configures en flex o flash)

Saludos!
Por: alfathenus
me sigue mandando el error "Incorrect number of arguments.Expected 2"
Para TabularPrint.fromDataGrid(dataGrid);
que argumentos hay que mandarle???
Por: marcos-blog
Lee el codigo... le tenes q pasar un segundo parametro q sea un objeto TabularPrintOptions
Por: alfathenus
envio este parametro: TabularPrint.fromDataGrid(dataGrid, options:viewPageNumber:true);
y me resulta el error:
expecting rightparen before colon.
ya no se que hacer...
mejor un ejemplo...
Por: marcos -blog
Hola marcos-blog.

De donde sacaste esto???

Código :

options:viewPageNumber:true

Eso no existe en AS3

Marcos, no lo tomes a mal? pero sabes algo de AS3? por tus preguntas veo q sos realmente nuevo directamente en la programacion...

Mira, lo q tenes q ahcer es crear un objeto TabularPrintOptions:

Código :

var optins:TabularPrintOptions = new TabularPrintOptions();
options.viewPageNumber = true;
TabularPrint.fromDataGrid(dataGrid, options);


Eso es lo q necesitas para q pasarle parametros.

A mi recomendacion, creo q deberias leer algun manual de as3 ya q tus preguntas son muy basicas y por eso te estas pegando la cabeza contra la pared una y otra vez (no lo tomes a mal por favor). Tambien estaria bueno q leas la documentacion de la clase, alli habian ejemplos de hacer exactamente esto.

Saludos!
Por: alfathenus
Hola, antes gracias a alfathenus por el artículo, sin embargo al imprimir crea una caja en la aplicación con estos datos: numero de columnas y numero de página, esto me desplaza la aplicación hacia abajo, saben cómo puedo evitar esto? ya que me interesa que los datos aparezcan en la hoja impresa, pero no en mi aplicación, poniendo las opciones en false me sigue creando la caja. Agradezco cualquier aporte.
Por: nuncaestuvo
utilice los packeje todo parece indicar que funciona bien! pero ahora como le hago para que las columnas se impriman con las mismas dimensiones del datagrid, unos amplios y otros no!..
Por: Elias-blog
gracis por la ayuda! pero es la verdad, estoy empezando con lo de la programacion y aun maestro observe que programa en Flex usando AS y entonces estoy en eso!
lo primero que hice fue implementar el datagrid con una base de datos con la ayuda del asistente de flex! perdon por la molestia. Gracias!
Por: marcos-blog
Elias, si es una falencia de esta clase.

El sistemita de impresion lo acabo de reescribir completamente y acepta lo q indicas... en cuanto pueda publico el codigo

Saludos!
Por: alfathenus
Paso de nuevo por aqui y todavia no publican el sistemita de impresion en su version final.
Gracias!
Por: Elias-blog
Elias, no, no subi la version final.... por 2 motivos, 1 aun no esta terminado el testing, 2 esto no es un delivery... cuando el laburo me permita llegar antes de las 22 a casa (porq en la oficina no tengo permiso de upload) lo terminare de testear, armar un tip/post para la comunidad y subir un proyecto de ejemplo a mi servidor....

Saludos!
Por: alfathenus
Excelente el código, pero tengo el el problemas que neesito imprimir varias AdvancedDataGRid de una vez...esta esta todas (son 5) con ntenidase ne un componente y al presionar "print"...debo imprimirlas toda. Como podría modificar estas clases para lograrf esto??..gracias por el apoyo
Por: Fernando-blog
Buenisima y muy útil. Gracias
Por: tonilopez-blog
Deja un comentario
IMPORTANTE

Recuerda ser respetuoso, no insultes a otras personas, ni uses palabrotas, hay una persona al otro lado de la pantalla.

Habla bien, NO ESCRIBAS EN MAYUSCULA TODO, no escribas como en un SMS, evita cosas como "ke", "x q" y demás abreviaciones.

Aquí funcionan las etiquetas de los foros, puedes usar [b] para negrita, [img] para las imágenes, [url] para los enlaces, etc.

Si tienes preguntas técnicas, envíalas mejor al foro.