5/7/2010 12:07:23 AM
Title:
datagrid paging
Hi,
Please provide the example for this datagrid paging
5/7/2010 12:14:02 AM
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;
}
//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;
}
}
//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;
}
[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;
}
}
}
}