I find my mistakes.
I miss adding the cellrender property in the PrintDataGrid.
And another questions:
When i dynamiclly load a image, the image disappears in the printed papaer. Am i missing something again?
On 11/16/05, Zhu Feng <
[EMAIL PROTECTED]> wrote:
Thank you, Patil.
But I can not access the url. would you attach the source code?On 11/15/05, Sandip Patil < [EMAIL PROTECTED] > wrote:Here is the link regarding data grid examples.Which also contains printing of datagrid.Just see demo examples & then go through source code.http://philflash.inway.fr/example.html
Zhu Feng < [EMAIL PROTECTED]> wrote:Hi, All,
does the Flexprintdatagrid support printing pictures?
when I use the browser's print, it works correctly, while when i use my own funciton of printing, something seems wrong.
and My codes are like this:
PicForm.mxml :
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml " xmlns:local="*">
<mx:Script>
<![CDATA[
// Data includes URL to album cover.
import mx.print.FlexPrintJob;
import mx.collections.ArrayCollection;
[Bindable]
public var initDG:Array = [
{ Artist:'Pavement', Album:'Slanted and Enchanted', Price:11.99,
Cover:'robot.jpg'},
{ Artist:'Pavement', Album:'Brighten the Corners', Price:11.99,
Cover:'rover.jpg'}
];
public function dgprint():Void{
var pj:FlexPrintJob = new FlexPrintJob();
if(pj.start())
{
var numRows:uint = myGrid.dataProvider ? myGrid.dataProvider.length : 0;
trace("!!!ZF, numRows = " + numRows );
// var view:FormView = new FormView();
var ptl:PrintTL = new PrintTL();
ptl.width=pj.pageWidth;
ptl.height=pj.pageHeight;
addChild(ptl);
var length:int = myGrid.columnCount;
var array:Array = new Array();
var i:int;
for(i = 0; i < length; i ++){
array.push(myGrid.getColumnAt(i).columnName);
}
ptl.columns = array;
ptl.ini();
ptl.pdg.dataProvider = this.myGrid.dataProvider;
var headerShift:int = ptl.pdg.showHeaders ? 1 : 0;
trace("!!! ptl.pdg.showHeaders ?" + ptl.pdg.showHeaders);
trace(" ptl.pdg.columnCount:" + ptl.pdg.columnCount);
if((ptl.pdg.vPosition + (ptl.pdg.rowCount - headerShift)) >= numRows)
{
pj.addObject(ptl);
}
else
{
pj.addObject(ptl);
while(true)
{
ptl.pdg.nextPage();
if((ptl.pdg.vPosition + (ptl.pdg.rowCount - headerShift)) >= numRows)
{
if(ptl.pdg.vPosition >= numRows)
{
ptl.pdg.height = 0;
ptl.pdg.visible = false;
}
pj.addObject(ptl);
break;
}
else
{
pj.addObject(ptl);
}
}
}
pj.send();
removeChild(ptl);
}
delete pj;
}
]]>
</mx:Script>
<mx:DataGrid id="myGrid" dataProvider="{initDG}"
variableRowHeight="true">
<mx:columns>
<mx:DataGridColumn columnName="Artist"/>
<mx:DataGridColumn columnName="Album"/>
<mx:DataGridColumn columnName="Cover"
cellRenderer="RendererDGImage"/>
<mx:DataGridColumn columnName="Price"/>
</mx:columns>
</mx:DataGrid>
<mx:Button id="btn" label="print form" click="dgprint()"/>
</mx:Application>
and the PrintTL.mxml:
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx=" http://www.macromedia.com/2005/mxml" xmlns="*" creationComplete="ini()">
<mx:Script>
<![CDATA[
public var columns:Array = new Array();
public function ini():Void{
var name:String = "";
var i:int;
for(i = 0; i < columns.length; i ++){
name = columns[i].toString();
pdg.addColumn(name);
}
}
]]>
</mx:Script>
<mx:PrintDataGrid id="pdg">
</mx:PrintDataGrid>
</mx:VBox>
--
Best Regards!
Zhu Feng
MSN: [EMAIL PROTECTED]
Yahoo! FareChase - Search multiple travel sites in one click.
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
SPONSORED LINKS
Web site design development Computer software development Software design and development Macromedia flex Software development best practice
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
--
Best Regards!
Zhu Feng
MSN: [EMAIL PROTECTED]
--
Best Regards!
Zhu Feng
MSN: [EMAIL PROTECTED]
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.