Comunidad de diseño web y desarrollo en internet online

Titulo o header a una impresion de datagrid

Citar            
MensajeEscrito el 20 Oct 2006 08:42 pm
Buenas a todos... he encontrado un codigo para imprimir la info de un datagrid y perfecto imprime, pero es necesario colocarle un titulo, he intentado con varias funciones y ninguna me sirve..
Alguien sabe de ello?

Aqui esta el codigo encontrado...

Código :

function doPrint(datagrid:mx.controls.DataGrid, fitPage:Boolean):Void {
if (fitPage == undefined) fitPage = true;
var pj:PrintJob = new PrintJob();


// position of currently visible rows stored
var prev_vPosition:Number = datagrid.vPosition;
var prev_width:Number = datagrid.width;
var prev_height:Number = datagrid.height;
var prev_vScroll = datagrid.vScrollPolicy;
var prev_selectedIndex = datagrid.selectedIndex;
var dgPrintWidth:Number = 0;
var dgPrintHeight:Number = 0;

if (pj.start() != true) {
return;
}
// hide scrollbar for print
datagrid.vScrollPolicy = "off";
// hide the selection
datagrid.selectedIndex = undefined;

// datagrid width for printing
if (fitPage) {
dgPrintWidth = pj.pageWidth;
} else {
if (prev_width < pj.pageWidth) {
dgPrintWidth = prev_width;
} else {
dgPrintWidth = pj.pageWidth;
}
}

var texto = pj.createTextField("Prueba" );
// number of rows per view, ignoring fractions (floor)
var rowsPerPage:Number = Math.floor((pj.pageHeight-datagrid.headerHeight)/datagrid.rowHeight);
// total number of pages to be printed, if there are any fractions, have one page for that (ceil)
var total_pages:Number = Math.ceil(datagrid.dataProvider.length/rowsPerPage);
// number of full pages to be printed, ignoring fractions (floor)
var full_pages:Number = Math.floor(datagrid.dataProvider.length/rowsPerPage);
// number of rows on last page if partial
var last_page_rows:Number = 0;
// height of last page if partial
var last_page_height:Number = 0;
// partial last page ?
if (total_pages != full_pages) {
last_page_rows = datagrid.dataProvider.length - (full_pages*rowsPerPage);
last_page_height = datagrid.headerHeight + (datagrid.rowHeight * last_page_rows);
}
// datagrid height for printing
dgPrintHeight = datagrid.headerHeight + (datagrid.rowHeight * rowsPerPage);
datagrid.setSize(dgPrintWidth, dgPrintHeight);

for (var i = 0; i<total_pages; i++) {
// if last page and partial - resize grid
if ((i == total_pages - 1) && (last_page_rows > 0)) {
datagrid.setSize(dgPrintWidth, last_page_height);
}
// move the visible row position.
datagrid.vPosition = i*rowsPerPage;
// size box relative to the grid
var b = {xMin:0, xMax:datagrid.width, yMin:0, yMax:datagrid.height};
if (!fitPage && prev_width < pj.pageWidth) {
var x0 = (pj.pageWidth - prev_width) / 2;
b = {xMin:(-x0), xMax:(datagrid.width+x0), yMin:0, yMax:datagrid.height};
}
pj.addPage(datagrid, b);
}
pj.send();
delete pj;
// previous scrollPolicy
datagrid.vScrollPolicy = prev_vScroll;
// position of currently visible rows restored
datagrid.setSize(prev_width, prev_height);
datagrid.selectedIndex = prev_selectedIndex;
datagrid.vPosition = prev_vPosition;
}


Saludos ^^


usa las etiquetas code para postear tu codigo

Por tuxa

5 de clabLevel



Genero:Femenino  

firefox
Citar            
MensajeEscrito el 27 Oct 2006 05:22 pm
:D
Hola Yo utilice tu codigo para imprimir el contenido de un datagrid
lo que yo hice fue
1. Copiar toda esa funcion, en un frame de la pelicuala pero quite la line de donde hay varible del texto (var texto = pj.createTextField("Prueba")
2. Despues cree el datagrid con un nombre en la instancia (por ejemplo datagrid_personas)
3. cree un boton para ejecutar la impresion donde el codigo es

Código :

on(press){
nombredelafuncion(nombredel datagriddelainstancia)
esta es la funcion tuya(datagrid_peronas)
}

4listo
Gracias si no te funciona escribe de nuevo
chao

usa las etiquetas code para postear tu codigo

Por wilsonmg

3 de clabLevel



Genero:Masculino  

Estudiante

msie
Citar            
MensajeEscrito el 03 Nov 2006 01:07 pm
Hola, mira q dando la info en el datagrid es perfecta... pero necesito es colocarle como encabezados y pie de pagina... bueno algo como


2006-11-03 -- Reporte XXXXX -----


Reportes impreso



Página 1/1


Algo de ese estilo

Por tuxa

5 de clabLevel



Genero:Femenino  

firefox
Citar            
MensajeEscrito el 15 Nov 2006 03:19 pm
:o
Mira cuando dices que salga el reporte xxx no te entiendo
pero lo que debes hacer es
1. Crear un clip de pelicula dentro de la cual se inserta el datagrid
2.Dentro de el realizas las funciones para la fecha
3.despues en la instancia debes dar un nom nombre para la programacion y en la funcion debes escribir esta instancia por ejemplo clip_info.nombredela instancia del datagrid y despues el resto asi puesde realizar todas las funciones del datagrid
para imprimir hay una funcion que imprime un clip especifico ren el cual realizas la funcion de la fecha

Por wilsonmg

3 de clabLevel



Genero:Masculino  

Estudiante

msie
Citar            
MensajeEscrito el 08 Dic 2010 08:49 pm
Gracias wilsonmg tienes mucha razon la unica forma de imprimir un datagrid con vista previa de impresion es creando un movieclip y enviarlo a imprimir pero envez de enviar el DG envias addpage(0,{xx, xx, xx, xx});

pj.addPage(datagrid, b,1);//Esto ya no es mejor usa esto:

pj.addPage (0,{xMin : 0, xMax:3508, yMin: 0, yMax: 2480})

espero te sea de ayuda

Por CLAnonimo

Claber

600 de clabLevel

5 tutoriales
1 articulo

 

Este es un usuario anónimo genérico para las cuentas borradas o perdidas.

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.