Hi you can use PagebleArrayCollection for DataGrid Pagination. Use
Following Code -
package
{
import mx.collections.ArrayCollection;
import mx.controls.Alert;
public class PagableArrayCollection extends ArrayCollection
{
public function PagableArrayCollection(source:Array=null){
super();
this.source = source;
pages=0;
setFilter();
}
//Private variables
private var _pages:Number;
private var _itemsPerPage:Number= 10;
private var _currentPage:Number = 1;
private var _maxIndex:Number = 10;
private var _minIndex:Number = 0;
//private methods
private function set pages(value:Number):void{
if(this.source.length % this.itemsPerPage == 0){
_pages = this.source.length/this.itemsPerPage;
}
else{
_pages = int(this.source.length/this.itemsPerPage)+1;
}
}
private function filterData(item:Object):Boolean{
return (this.getItemIndex(item) >= _minIndex &&
this.getItemIndex(item) <= _maxIndex)
}
//public methods
[Bindable]
public function get itemsPerPage():Number{
return _itemsPerPage;
}
public function set itemsPerPage(value:Number):void{
_itemsPerPage = value;
this.pages = 0;
if(this.currentPage > this.pages){
this.currentPage = this.pages;
}
}
[Bindable]
public function get currentPage():Number{
return _currentPage;
}
public function set currentPage(value:Number):void{
_currentPage = value;
setFilter();
}
[Bindable]
public function get pages():Number{
return _pages;
}
public function pageUp():void{
if(this.currentPage < this.pages){
this.currentPage += 1;
}
}
public function pageDown():void{
if(this.currentPage > 1){
this.currentPage -= 1;
}
}
public function pageFirst():void{
if(this.currentPage > 1){
//Alert.show("Yes, got the action");
this.currentPage = (pages + 1) - pages;
}
}
public function pageLast():void{
if(this.currentPage < this.pages){
this.currentPage = pages;
}
}
}
}
On May 7, 12:03 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].
> For more options, visit this group
> athttp://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.