2 Replies Latest reply on May 5, 2011 10:17 PM by new flex guy

    how to print <s:List data in flex 4

    new flex guy Level 1

      <?xml version="1.0" encoding="utf-8"?>

      <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"

         xmlns:s="library://ns.adobe.com/flex/spark"

         xmlns:mx="library://ns.adobe.com/flex/mx"

         width="950" height="600" >

      <s:layout>

      <s:VerticalLayout/>

      </s:layout>

       

      <fx:Script>

      <![CDATA[

      import mx.controls.Alert;

      import mx.printing.FlexPrintJob;

      import mx.printing.FlexPrintJobScaleType;

      protected function button1_clickHandler(event:MouseEvent):void

      {

      lstStudentData.dataProvider = arrCol_Div_Chars;

      }

       

      protected function btnPrint_clickHandler():void

      {

        // WANT TO WRITE PRINT CODE HERE

      }

       

      ]]>

      </fx:Script>

       

      <fx:Declarations>

      <s:ArrayCollection id="arrCol_Div_Chars">

      <fx:Object label='A' />

      <fx:Object label='B' />

      <fx:Object label='C' />

      <fx:Object label='D' />

      <fx:Object label='E' />

      <fx:Object label='F' />

      <fx:Object label='G' />

      <fx:Object label='H' />

      <fx:Object label='I' />

      <fx:Object label='J' />

      <fx:Object label='K' />

      <fx:Object label='L' />

      <fx:Object label='M' />

      <fx:Object label='N' />

      <fx:Object label='O' />

      <fx:Object label='P' />

      <fx:Object label='Q' />

      <fx:Object label='R' />

      <fx:Object label='S' />

      <fx:Object label='T' />

      <fx:Object label='U' />

      <fx:Object label='V' />

      <fx:Object label='W' />

      <fx:Object label='X' />

      <fx:Object label='Y' />

      <fx:Object label='Z' />

      </s:ArrayCollection>

      </fx:Declarations>

       

      <s:VGroup>

      <s:Button label="Show " click="button1_clickHandler(event)" />

      <s:Button label="Print" click="btnPrint_clickHandler()" />

      </s:VGroup>

       

      <s:List width="900" height="500"  id="lstStudentData"   itemRenderer="compononts.CustomListItemRenderer"

      useVirtualLayout="true"   >

      <s:layout >

      <s:TileLayout requestedColumnCount="2" horizontalAlign="center" verticalAlign="middle"

         />

      </s:layout>

       

      </s:List>

       

      </s:WindowedApplication>

        • 1. Re: how to print <s:List data in flex 4
          mattcom Level 1

                    private function printHandler(graphic:UIComponent):void
                      {
                          var printJob:FlexPrintJob = new FlexPrintJob();
                          printJob.start();
                          printJob.addObject(graphic, FlexPrintJobScaleType.MATCH_HEIGHT);
                          printJob.send();
                      }

           

           

          <s:Button label="Print" click="printHandler(lstStudentData)" />

           

           

          the code works with Flex 3 to print pretty much anything.  I'm not sure about Flex 4.

          • 2. Re: how to print <s:List data in flex 4
            new flex guy Level 1

            hey frnd,

            it is not working for me

            is any solution or trick there?

            thx in advanced,