Hi,      I have requirement like a Grid with some 10 grid row.. and each row
is having around 50 elements..
some thing like
  firstname       secondname     thirdname      ......... around 50 items
  firstname1
  ..............
   .............
   around 10 items.

  My screen will be showing 6 columns and the complete (10) row..
  When i click print... the first 6 columns will come and below this
  next 6 columns i.e 7-12 column index will come like wise the complete
  50 rows..

  I have done a POC for this, I am able to print, but everything is coming
in a
  single page with scroll bar in the page.. i want multiple pages if a
single page
  is having more than 24 columns (6columns x 4sets)

  As the multiple pages requirement is critical can somebody help me out,
  to fix this issue

  for some reason i cannot use PrintDataGrid in my Print format..otherwise
  i could use attribute validNextPage and method nextPage() to achieve this.

  I am sharing the entire POC code..

  Thanks in advance

components . GridPrintViewMx.mxml

 <?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"; width="100%"
height="100%" horizontalAlign="center">
<mx:Repeater id="boxRp">
<mx:HBox width="550" height="200" borderColor="#000000" borderThickness="2"
borderStyle="solid" horizontalAlign="left" verticalAlign="middle"
paddingLeft="10"     paddingRight="10" horizontalScrollPolicy="off"
verticalScrollPolicy="off">

<mx:Repeater id="rptr" dataProvider="{boxRp.currentItem}">
   <mx:Grid borderColor="#FFFFFF" borderStyle="solid" borderThickness="2">
       <mx:GridRow>
             <mx:GridItem>
                <mx:HBox>
                 <mx:Label id="text1" text="{rptr.currentItem.firstName}"/>
                </mx:HBox>
            </mx:GridItem>
            </mx:GridRow>
            <mx:GridRow>
             <mx:GridItem>
                <mx:HBox>
                 <mx:Label id="text2" text="{rptr.currentItem.secondName}"/>
                </mx:HBox>
             </mx:GridItem>
            </mx:GridRow>
            <mx:GridRow>
            <mx:GridItem>
                <mx:HBox>
                 <mx:Label id="text3" text="{rptr.currentItem.middleName}"/>
                </mx:HBox>
             </mx:GridItem>
            </mx:GridRow>
       </mx:Grid>

       <mx:Spacer width="10"/>
</mx:Repeater>
 </mx:HBox>

</mx:Repeater>
</mx:VBox>


PrintTest.mxml


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="horizontal" creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.printing.FlexPrintJobScaleType;
import mx.printing.FlexPrintJob;
import components.GridPrintViewMx;
import mx.collections.ArrayCollection;
[Bindable]
var dp:ArrayCollection = new ArrayCollection();
[Bindable]
var tempArray:ArrayCollection = new ArrayCollection();
 public function init():void
{
}
 public function createData(items:int):void
{
var tempArray:ArrayCollection = new ArrayCollection();
if(dp.length > 0)
dp.removeAll();
for(var i:int = 0; i<items; i++)
{
var obj:Object = new Object();
obj.firstName = "first"+i;
obj.secondName = "second"+i;
obj.middleName = "middle"+i;
tempArray.addItem(obj);
}
dp = tempArray;
box.invalidateDisplayList();
}
        public function doPrint():void {
            // Create a FlexPrintJob instance.
            var printJob:FlexPrintJob = new FlexPrintJob();
            var oneRow:ArrayCollection = new ArrayCollection();
            // Start the print job.
            if (printJob.start()) {

                var thePrintView:GridPrintViewMx = new GridPrintViewMx();
                addChild(thePrintView);

                // Set the print view properties.
                thePrintView.width=printJob.pageWidth;
                thePrintView.height=printJob.pageHeight;

thePrintView.boxRp.dataProvider = createPrintGridData(dp as
ArrayCollection);


 printJob.addObject(thePrintView,FlexPrintJobScaleType.SHOW_ALL);

                removeChild(thePrintView);
            }
            // Send the job to the printer.
            printJob.send();
        }

        public function
createPrintGridData(gridData:ArrayCollection):ArrayCollection
        {
         var lastpoint:int = 0;
         if(gridData.length>0)
         {

         for(var i:int=1; i<=gridData.length ; i++)
         {
         if(i%6 == 0)
         {
         tempArray.addItem(gridData.toArray().slice(lastpoint,i));
         lastpoint = i;
         }
         }

         if(gridData.length%6 != 0)

tempArray.addItem(gridData.toArray().slice(lastpoint,gridData.length));

         }

         return tempArray;
        }
 ]]>
</mx:Script>
<mx:HBox id="box" width="500" height="200" borderColor="#000000"
borderThickness="2" borderStyle="solid" verticalAlign="middle"
paddingLeft="10" paddingRight="10">
 <mx:Repeater id="rptr" dataProvider="{dp}">

   <mx:Grid borderColor="#FFFFFF" borderStyle="solid" borderThickness="2">
       <mx:GridRow>
             <mx:GridItem>
                <mx:HBox>
                 <mx:Label id="text1" text="{rptr.currentItem.firstName}"/>
                </mx:HBox>
            </mx:GridItem>
            </mx:GridRow>
            <mx:GridRow>
             <mx:GridItem>
                <mx:HBox>
                 <mx:Label id="text2" text="{rptr.currentItem.secondName}"/>
                </mx:HBox>
             </mx:GridItem>
            </mx:GridRow>
            <mx:GridRow>
            <mx:GridItem>
                <mx:HBox>
                 <mx:Label id="text3" text="{rptr.currentItem.middleName}"/>
                </mx:HBox>
             </mx:GridItem>
            </mx:GridRow>

       </mx:Grid>

       <mx:Spacer width="10"/>
</mx:Repeater>
 </mx:HBox>
<mx:VBox>
    <mx:Button id="printDG"
        label="Print"
        click="doPrint();"/>
    <mx:HBox>
     <mx:TextInput id="items" width="50"/>
     <mx:Button id="itemsButton" label="Fill It"
click="createData(int(items.text))"/>
    </mx:HBox>
</mx:VBox>
</mx:Application>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to