private var index:uint = 0;
  public var pageSize:uint = 6;// should be same as row count of Datagrid
  public var navSize:uint = 5;
  //private var navPage:uint = 3;
  [Bindable]
  public var eventsCustomizationCollection:ArrayCollection=new
ArrayCollection();
  [Bindable]
  public var allEventsCollection:ArrayCollection=new ArrayCollection();
  [Bindable]
  public var allEventsDataPaginated:ArrayCollection=new ArrayCollection();
  [Bindable]


private function paginate(event:Event):void
  {
   allEventsCollection=EventModel.getInstance().allEventsCollection;
   refreshDataProvider(index);
   createNavBar(Math.ceil(allEventsCollection.length/pageSize));
  }

  private function createNavBar(pages:uint = 1,set:uint = 0):void
  {
   nav.removeAll();
   if( pages > 1 )
   {
    if( set != 0 )
    {
     nav.addItem({label:"<<",data:0});
     if( (set - navSize ) >= 0 )
     {
      nav.addItem({label:"<",data:set - navSize});
     }
     else
     {
      nav.addItem({label:"<",data:0});
     }
    }

    for( var x:uint = 0; x < navSize; x++)
    {
     var pg:uint = x + set;
     nav.addItem({label: pg + 1,data: pg});
    }
    if( pg < pages - 1 )
    {
     nav.addItem({label:">",data:pg + 1});
     nav.addItem({label:">>",data:pages - pageSize});
    }
   }
  }

  private function navigatePage(event:ItemClickEvent):void
  {
   refreshDataProvider(event.item.data);
   var lb:String = event.item.label.toString();
   if( lb.indexOf("<") > -1 || lb.indexOf(">") > -1 )
   {
    
createNavBar(Math.ceil(allEventsCollection.length/pageSize),event.item.data);
    if( event.item.data == 0 )
    {
     pageNav.selectedIndex = 0;
    }
    else
    {
     pageNav.selectedIndex = 2;
    }
   }

  }

  private function refreshDataProvider(start:uint):void
  {
   allEventsDataPaginated = new ArrayCollection(
allEventsCollection.toArray().slice((start * pageSize),(start * pageSize) +
pageSize) );
  }

and in datagrid :
<mx:DataGrid id="eventList"  sortableColumns="false"
resizableColumns="false"
 draggableColumns="false" dataProvider="{allEventsDataPaginated}"
rowCount="6"
 headerStyleName="allEventsHeading" styleName="datagridStyle"
verticalScrollPolicy="off">
On Fri, May 7, 2010 at 12:33 PM, Alekhya Krishna <[email protected]
> wrote:

> Hi,
>
> i want datagrid paging exampel, can any body having the code, please send
> me, I am using array collection.
>
> Thanks & Regards,
> K.V.Ramakrishna
>
> --
> 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]<flex_india%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/flex_india?hl=en.
>

-- 
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