Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Print With Flash And Datagrids Without Resizing!
sanbeand
post Nov 2 2005, 02:21 AM
Post #1


Member [Level 1]
****

Group: Members
Posts: 51
Joined: 28-October 05
From: mexico
Member No.: 13,497



hey hi guys..this is a code i used to print data from a datagrid and it is so useful in ur RIAs hope it helps...
cheers!


CODE
mybtn.onPress=function(){
doPrint(mydg, true)
}



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;
 }
}
// 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;
}


Notice from BuffaloHELP:
Last caution note. I PMed you about using CODE tags. You ignored it. Credits reduced.


This post has been edited by BuffaloHELP: Nov 2 2005, 02:28 AM
Go to the top of the page
 
+Quote Post
iGuest
post Jan 15 2008, 09:14 AM
Post #2


Trap Double Mocha Member
***************

Group: Members
Posts: 2,360
Joined: 21-September 07
Member No.: 50,369



Print script is usefull for me
Print With Flash And Datagrids Without Resizing!

Hey fri thanks for this useful script, its very useful

-reply by Rahul Kathet
Go to the top of the page
 
+Quote Post
iGuest
post Jun 16 2008, 09:52 PM
Post #3


Trap Double Mocha Member
***************

Group: Members
Posts: 2,360
Joined: 21-September 07
Member No.: 50,369



Great work
Print With Flash And Datagrids Without Resizing!

Useful truely this function. She is really amazing for anything concerning the printing of the Datagrid.

But I have a question is it possible to print a title to the table.

Thank's a lot

-reply by Anje
Go to the top of the page
 
+Quote Post
iGuest
post Jun 16 2008, 09:49 PM
Post #4


Trap Double Mocha Member
***************

Group: Members
Posts: 2,360
Joined: 21-September 07
Member No.: 50,369



A title
Print With Flash And Datagrids Without Resizing!

Hello,

Useful truely this function. She is really amazing for anything concerning the printing of the Datagrid.

But I have a question is it possible to print a title to the table.

Thanks a lot for this work.

Aj

-reply by Anje
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Macromedia Flash(9)
  2. How To Get High Quality Gif Images In Flash(0)
  3. Appeal For Flash-related Help [kinda Urgent](0)
  4. Playing Flash Movies Without The One-click Activation: Simple Insertion Of Javascript(3)
  5. Flash Player Simpleviewer Using Flickr And Picassa2(0)
  6. Here Is A Really Good Flash Tutorial Site(7)
  7. Flash, Sqlserver And Asp(0)
  8. Flash Tutorial : Realistic Ball Movement(0)
  9. Flash Vs. Java Applets(2)
  10. Flash(3)
  11. Need Sugation About Flash(4)
  12. Move The Movie Clip In Flash(2)
  13. Flash Coding(1)
  14. Flash - Streaming Flv With Interactible Objects(3)
  15. Flash Problem(9)
  1. Flash As3 Question(0)


 



- Lo-Fi Version Time is now: 25th July 2008 - 10:34 PM