开发时经常遇到用一个DataGrid分页显示数据的情况,然而Flex本身没有提供分页控件,给开发带来了不便。这里将自己开发时做的一个分页控件摆出来供刚入门的朋友参考。O(∩_∩)O~

 

 

 

采用BlazeDS与Java端通信

 

1. 一个Vo对象Page存放分页信息,以及相对应的Java端的Page对象

2. 一个很简单的自定义事件PageEvent

3. 调用。通过RemoteObject调用服务器的分页查询方法(返回值为Page对象)

 

 

一、JAVA端 

 

1、Page对象  (从SpringSide那借来的)

Java代码
  1. /**  
  2.  * 分页对象. 包含当前页数据及分页信息如总记录数.  
  3.  */   
  4. public   class  Page {  
  5. /**  
  6. * 默认每页记录数  
  7. */   
  8. private   static   final   int  DEFAULT_PAGE_SIZE =  20 ;  
  9.   
  10.   
  11. /**  
  12. * 每页的记录数  
  13. */   
  14. private   int  pageSize = DEFAULT_PAGE_SIZE;   
  15.   
  16. /**  
  17. * 当前页第一条数据在List中的位置,从0开始  
  18. */   
  19. private   long  start =  0 ;   
  20.    
  21. /**  
  22. * 总记录数  
  23. */   
  24. private   long  totalCount =  0 ;   
  25.   
  26. /**  
  27. * 总页数  
  28. */   
  29. @SuppressWarnings ( "unused" )  
  30. private   long  totalPageCount =  0 ;  
  31.    
  32.   
  33. /**  
  34. * 当前页数  
  35. */   
  36. @SuppressWarnings ( "unused" )  
  37. private   long  currentPageNo;  
  38.   
  39. /**  
  40. * 查询结果  
  41. */   
  42. private  List resultList;  
  43. }  
Java代码  收藏代码
  1. /** 
  2.  * 分页对象. 包含当前页数据及分页信息如总记录数. 
  3.  */  
  4. public class Page {  
  5. /** 
  6. * 默认每页记录数 
  7. */  
  8. private static final int DEFAULT_PAGE_SIZE = 20;  
  9.   
  10.   
  11. /** 
  12. * 每页的记录数 
  13. */  
  14. private int pageSize = DEFAULT_PAGE_SIZE;   
  15.   
  16. /** 
  17. * 当前页第一条数据在List中的位置,从0开始 
  18. */  
  19. private long start = 0;   
  20.    
  21. /** 
  22. * 总记录数 
  23. */  
  24. private long totalCount = 0;   
  25.   
  26. /** 
  27. * 总页数 
  28. */  
  29. @SuppressWarnings("unused")  
  30. private long totalPageCount = 0;  
  31.    
  32.   
  33. /** 
  34. * 当前页数 
  35. */  
  36. @SuppressWarnings("unused")  
  37. private long currentPageNo;  
  38.   
  39. /** 
  40. * 查询结果 
  41. */  
  42. private List resultList;  
  43. }  

 

 

2、查询方法接口

Java代码
  1. /**  
  2. * 分页查询  
  3. * @param condition 查询条件 (根据需求来定)  
  4. * @param pageNo  
  5. * @param pageSize  
  6. * @return  
  7. */   
  8. public  Page pagedQuery(String condition,  int  pageNo,  int  pageSize);  
Java代码  收藏代码
  1. /** 
  2. * 分页查询 
  3. * @param condition 查询条件 (根据需求来定) 
  4. * @param pageNo 
  5. * @param pageSize 
  6. * @return 
  7. */  
  8. public Page pagedQuery(String condition, int pageNo, int pageSize);  

 

 

二、Flex端 

 

1、Page对象(通过工具类生成)

Actionscript代码
  1. package lzh.demo.pagebar.model {  
  2. import mx.collections.ArrayCollection;  
  3. [RemoteClass(alias="lzh.demo.pagebar.model.Page" )]  
  4. [Bindable]  
  5. public class Page {  
  6. /**  
  7. * 默认每页记录数  
  8. */  
  9. public static const DEFAULT_PAGE_SIZE:int = 20 ;  
  10. /**  
  11. * 每页的记录数  
  12. */   
  13. public var pageSize:int = DEFAULT_PAGE_SIZE;   
  14. /**  
  15. * 当前页第一条数据在List中的位置,从0 开始  
  16. */   
  17. public var start:int;  
  18. /**  
  19. * 总记录数  
  20. */   
  21. public var totalCount:int;   
  22. /**  
  23. * 总页数  
  24. */   
  25. public var totalPageCount:int;   
  26. /**  
  27. * 当前页数  
  28. */   
  29. public var currentPageNo:int = 1 ;   
  30. /**  
  31. * 查询结果  
  32. */    
  33. public var resultList:ArrayCollection;  
  34. public function Page() {  
  35. }  
  36. public static function buildPage(item:Object) :  Page{  
  37. if(null==item) return null;  
  38. var page:Page = new Page();  
  39. page.pageSize = item.pageSize;  
  40. page.start = item.start;  
  41. page.data = item.data;  
  42. page.totalCount = item.totalCount;  
  43. page.totalPageCount = item.totalPageCount;  
  44. page.currentPageNo = item.currentPageNo;  
  45. page.resultList = item.resultList;  
  46. return page;  
  47. }  
  48. }  
  49. }   
Actionscript代码  收藏代码
  1. package lzh.demo.pagebar.model {  
  2. import mx.collections.ArrayCollection;  
  3. [RemoteClass(alias="lzh.demo.pagebar.model.Page")]  
  4. [Bindable]  
  5. public class Page {  
  6. /**  
  7. * 默认每页记录数  
  8. */  
  9. public static const DEFAULT_PAGE_SIZE:int = 20;  
  10. /**  
  11. * 每页的记录数  
  12. */   
  13. public var pageSize:int = DEFAULT_PAGE_SIZE;   
  14. /**  
  15. * 当前页第一条数据在List中的位置,从0开始  
  16. */   
  17. public var start:int;  
  18. /**  
  19. * 总记录数  
  20. */   
  21. public var totalCount:int;   
  22. /**  
  23. * 总页数  
  24. */   
  25. public var totalPageCount:int;   
  26. /**  
  27. * 当前页数  
  28. */   
  29. public var currentPageNo:int = 1;   
  30. /**  
  31. * 查询结果  
  32. */    
  33. public var resultList:ArrayCollection;  
  34. public function Page() {  
  35. }  
  36. public static function buildPage(item:Object) :  Page{  
  37. if(null==item) return null;  
  38. var page:Page = new Page();  
  39. page.pageSize = item.pageSize;  
  40. page.start = item.start;  
  41. page.data = item.data;  
  42. page.totalCount = item.totalCount;  
  43. page.totalPageCount = item.totalPageCount;  
  44. page.currentPageNo = item.currentPageNo;  
  45. page.resultList = item.resultList;  
  46. return page;  
  47. }  
  48. }  
  49. }   

 

 

2、PageEvent

Actionscript代码
  1. package lzh.demo.pagebar.event {  
  2. import flash.events.Event;  
  3. import lzh.demo.pagebar.model.Page;  
  4. public class PageEvent extends Event {  
  5. public var page:Page;  
  6. public function PageEvent(page:Page, type:String) {  
  7. super(type);  
  8. this.page = page;  
  9. }  
  10. public override function clone():Event{  
  11. return new PageEvent(page, type);  
  12. }  
  13. }  
  14. }  
Actionscript代码  收藏代码
  1. package lzh.demo.pagebar.event {  
  2. import flash.events.Event;  
  3. import lzh.demo.pagebar.model.Page;  
  4. public class PageEvent extends Event {  
  5. public var page:Page;  
  6. public function PageEvent(page:Page, type:String) {  
  7. super(type);  
  8. this.page = page;  
  9. }  
  10. public override function clone():Event{  
  11. return new PageEvent(page, type);  
  12. }  
  13. }  
  14. }  

 

 

3、PageBar

Actionscript代码
  1. <?xml version= "1.0"  encoding= "utf-8" ?>  
  2. <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"   
  3. verticalAlign="bottom"   
  4. creationComplete="init()"  horizontalGap= "4" >  
  5. <mx:Metadata>  
  6.     [Event(name="goPage" ,type= "lzh.demo.pagebar.event.PageEvent" )]  
  7. </mx:Metadata>  
  8. <mx:Script>  
  9. <![CDATA[  
  10. import lzh.demo.pagebar.event.PageEvent;  
  11. import lzh.demo.pagebar.model.Page;  
  12. import mx.events.ListEvent;  
  13. import mx.events.NumericStepperEvent;  
  14. private var _page:Page;  
  15. [Bindable]  
  16. public function set page(page:Page):void{  
  17. _page = page;   
  18. configPageBar();  
  19. }  
  20. public function get page():Page{  
  21.     return _page;   
  22. }  
  23. [Bindable]  
  24. /**  
  25. * 在HorizontalList中显示的页码  
  26. */   
  27. public var pageNumbers:Array=[];  
  28. /**  
  29. * HorizontalList中显示的最大数字  
  30. */   
  31. private static const SIZE:int = 10 ;   
  32. /**  
  33. * HorizontalList左边显示的数量  
  34. */   
  35. private static const LEFT_SIZE:int = 2 ;   
  36. private function init():void{  
  37. if(null==_page) {  
  38.     _page = new Page();  
  39. }  
  40. configPageBar();  
  41. }  
  42. /**  
  43. * 配置PageBar  
  44. */   
  45. private function configPageBar():void{  
  46. configPageNumbers();  
  47. hbFirst.addChild(lbtnFirst);  
  48. hbPrev.addChild(btnPrev);  
  49. hbNext.addChild(btnNext);  
  50. hbLast.addChild(lbtnLast);  
  51. // 左边的显示:首页\上一页  
  52. if (1 ==_page.currentPageNo){  
  53.     hbFirst.removeChild(lbtnFirst);  
  54.     hbPrev.removeChild(btnPrev);  
  55. } else if((1 <_page.currentPageNo) && (_page.currentPageNo<= 4 )){  
  56.     hbFirst.removeChild(lbtnFirst);  
  57. }  
  58. // 右边的显示:下一页\尾页  
  59. if (_page.totalPageCount<=_page.currentPageNo){  
  60.     hbLast.removeChild(lbtnLast);  
  61.     hbNext.removeChild(btnNext);  
  62. } else if(pageNumbers.indexOf(_page.totalPageCount)>-1 ){  
  63.     hbLast.removeChild(lbtnLast);  
  64. }  
  65. hListNumbers.columnCount = pageNumbers.length;  
  66. }   
  67. /**  
  68. * 配置显示的可选页码  
  69. */    
  70. private function configPageNumbers():void{  
  71. pageNumbers = [];  
  72. if (_page.totalPageCount<1 ){ // 总页数为 0   
  73.     return;  
  74. }  
  75. var i:int=0 ;  
  76. if (_page.currentPageNo<4  ){  
  77. for(i=1 ; i<=_page.currentPageNo; i++){ //将<=currentPageNo的页码加入  
  78. pageNumbers.push(i);  
  79. }  
  80. } else {  
  81. for(i=LEFT_SIZE; i>=0 ; i--){   
  82.     pageNumbers.push(_page.currentPageNo-i);  
  83. }  
  84. }  
  85. // 从currentPage后起,分别加入,总数不超过10   
  86. for(i=1 ; pageNumbers.length<SIZE && (_page.currentPageNo+i)<=_page.totalPageCount; i++){  
  87.     pageNumbers.push(_page.currentPageNo+i);  
  88. }  
  89. if((pageNumbers.length<SIZE)   
  90.     &&  
  91.     pageNumbers.indexOf(_page.totalPageCount)>-1    
  92.     &&   
  93.     (pageNumbers.indexOf(1 )==- 1 )){  
  94. pageNumbers = [];  
  95. i =((_page.totalPageCount<SIZE)?_page.totalPageCount:SIZE) - 1 ;  
  96. for ( ; i>=0 ; i--){  
  97.     pageNumbers.push(_page.totalPageCount-i);  
  98. }  
  99. }  
  100. hListNumbers.selectedItem = _page.currentPageNo;  
  101. }  
  102. protected function btnPrev_clickHandler(event:MouseEvent):void {  
  103.     goPage((hListNumbers.selectedItem as uint) - 1 );  
  104. }  
  105. protected function btnNext_clickHandler(event:MouseEvent):void {  
  106.     goPage((hListNumbers.selectedItem as uint) + 1 );  
  107. }  
  108. /**  
  109. * 向上分发事件,一般情况下,需要与服务器端通信  
  110. */   
  111. private function goPage(pageNo:uint):void{  
  112.     _page.currentPageNo = pageNo;  
  113.     this.dispatchEvent(new PageEvent(_page, "goPage" ));  
  114. }  
  115. protected function hListNumbers_changeHandler(event:ListEvent):void {  
  116.     goPage(hListNumbers.selectedItem as uint);  
  117. }  
  118. protected function lbtnFirst_clickHandler(event:MouseEvent):void {  
  119.     goPage(1 );  
  120. }  
  121. protected function lbtnLast_clickHandler(event:MouseEvent):void {  
  122.     goPage(_page.totalPageCount);  
  123. }  
  124. protected function pageSize_changeHandler(event:NumericStepperEvent):void {  
  125. _page.totalPageCount = _page.totalCount / pageSize.value;  
  126. _page.totalPageCount += ((_page.totalCount % pageSize.value)>0 )? 1 : 0 ;  
  127. if (_page.totalPageCount>0 ){  
  128.     _page.currentPageNo = 1 ;  
  129.     goPage(_page.currentPageNo);  
  130. }  
  131. }  
  132. protected function btnGo_clickHandler(event:MouseEvent):void {  
  133. var pageNo:int = (Number)(targetPageNo.text);  
  134. if (0 ==pageNo) {  
  135.     targetPageNo.text = 1  +  "" ;  
  136. }  
  137. if(pageNo<=0 ){  
  138.     targetPageNo.text = 1  +  "" ;  
  139. }  
  140. if (pageNo>_page.totalPageCount){  
  141.     targetPageNo.text = _page.totalPageCount + "" ;  
  142. }  
  143. pageNo = (Number)(targetPageNo.text);  
  144. goPage(pageNo);  
  145. }  
  146. ]]>  
  147. </mx:Script>  
  148. <mx:Text text="{page.totalCount+'条记录'}"  />  
  149. <mx:Text text="每页" />  
  150. <mx:NumericStepper id="pageSize"    
  151.   minimum="10"  stepSize= "5"  maximum= "5000"  value= "20"    
  152.   change="pageSize_changeHandler(event)" />  
  153. <mx:HBox id="hbFirst" >  
  154. <mx:LinkButton id="lbtnFirst"  label= "1..."  fontWeight= "normal"  click= "lbtnFirst_clickHandler(event)" />  
  155. </mx:HBox>  
  156. <mx:HBox id="hbPrev" >  
  157.     <mx:Button id="btnPrev"  icon= "@Embed(source='/assets/prev_page.gif')"  enabled= "{1!=hListNumbers.selectedItem}"  toolTip= "上一页"  click= "btnPrev_clickHandler(event)"  cornerRadius= "20"  alpha= "1.0"  borderColor= "#FDFDFD"  width= "30" />  
  158. </mx:HBox>  
  159. <mx:HorizontalList id="hListNumbers"  dataProvider= "{pageNumbers}"    
  160.   columnCount="10"  columnWidth= "22"    
  161.   borderStyle="none"  backgroundColor= "#FFFFFF"  height= "23"   
  162.   change="hListNumbers_changeHandler(event)" >  
  163. </mx:HorizontalList>  
  164. <mx:HBox id="hbNext" >  
  165.     <mx:Button id="btnNext"  icon= "@Embed(source='assets/next_page.gif')"  enabled= "{page.totalPageCount!=hListNumbers.selectedItem}"  toolTip= "下一页"     click= "btnNext_clickHandler(event)"  cornerRadius= "20"  borderColor= "#F9FBFC"  width= "30" />  
  166. </mx:HBox>  
  167. <mx:HBox id="hbLast" >  
  168.     <mx:LinkButton id="lbtnLast"  label= "{'...'+page.totalPageCount}"  fontWeight= "normal"  click= "lbtnLast_clickHandler(event)" />  
  169. </mx:HBox>  
  170. <mx:TextInput maxChars="3"  restrict= "0-9"  textAlign= "right"  id= "targetPageNo" />  
  171. <mx:Button label="Go"  cornerRadius= "10"  width= "50"  id= "btnGo"  click= "btnGo_clickHandler(event)" />  
  172. </mx:HBox>  
Actionscript代码  收藏代码
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"  
  3. verticalAlign="bottom"  
  4. creationComplete="init()" horizontalGap="4">  
  5. <mx:Metadata>  
  6.     [Event(name="goPage",type="lzh.demo.pagebar.event.PageEvent")]  
  7. </mx:Metadata>  
  8. <mx:Script>  
  9. <![CDATA[  
  10. import lzh.demo.pagebar.event.PageEvent;  
  11. import lzh.demo.pagebar.model.Page;  
  12. import mx.events.ListEvent;  
  13. import mx.events.NumericStepperEvent;  
  14. private var _page:Page;  
  15. [Bindable]  
  16. public function set page(page:Page):void{  
  17. _page = page;   
  18. configPageBar();  
  19. }  
  20. public function get page():Page{  
  21.     return _page;   
  22. }  
  23. [Bindable]  
  24. /**  
  25. * 在HorizontalList中显示的页码  
  26. */   
  27. public var pageNumbers:Array=[];  
  28. /**  
  29. * HorizontalList中显示的最大数字  
  30. */   
  31. private static const SIZE:int = 10;   
  32. /**  
  33. * HorizontalList左边显示的数量  
  34. */   
  35. private static const LEFT_SIZE:int = 2;   
  36. private function init():void{  
  37. if(null==_page) {  
  38.     _page = new Page();  
  39. }  
  40. configPageBar();  
  41. }  
  42. /**  
  43. * 配置PageBar  
  44. */   
  45. private function configPageBar():void{  
  46. configPageNumbers();  
  47. hbFirst.addChild(lbtnFirst);  
  48. hbPrev.addChild(btnPrev);  
  49. hbNext.addChild(btnNext);  
  50. hbLast.addChild(lbtnLast);  
  51. // 左边的显示:首页\上一页  
  52. if (1==_page.currentPageNo){  
  53.     hbFirst.removeChild(lbtnFirst);  
  54.     hbPrev.removeChild(btnPrev);  
  55. } else if((1<_page.currentPageNo) && (_page.currentPageNo<=4)){  
  56.     hbFirst.removeChild(lbtnFirst);  
  57. }  
  58. // 右边的显示:下一页\尾页  
  59. if (_page.totalPageCount<=_page.currentPageNo){  
  60.     hbLast.removeChild(lbtnLast);  
  61.     hbNext.removeChild(btnNext);  
  62. } else if(pageNumbers.indexOf(_page.totalPageCount)>-1){  
  63.     hbLast.removeChild(lbtnLast);  
  64. }  
  65. hListNumbers.columnCount = pageNumbers.length;  
  66. }   
  67. /**  
  68. * 配置显示的可选页码  
  69. */    
  70. private function configPageNumbers():void{  
  71. pageNumbers = [];  
  72. if (_page.totalPageCount<1){ // 总页数为0  
  73.     return;  
  74. }  
  75. var i:int=0;  
  76. if (_page.currentPageNo<4 ){  
  77. for(i=1; i<=_page.currentPageNo; i++){ //将<=currentPageNo的页码加入  
  78. pageNumbers.push(i);  
  79. }  
  80. } else {  
  81. for(i=LEFT_SIZE; i>=0; i--){   
  82.     pageNumbers.push(_page.currentPageNo-i);  
  83. }  
  84. }  
  85. // 从currentPage后起,分别加入,总数不超过10  
  86. for(i=1; pageNumbers.length<SIZE && (_page.currentPageNo+i)<=_page.totalPageCount; i++){  
  87.     pageNumbers.push(_page.currentPageNo+i);  
  88. }  
  89. if((pageNumbers.length<SIZE)   
  90.     &&  
  91.     pageNumbers.indexOf(_page.totalPageCount)>-1   
  92.     &&   
  93.     (pageNumbers.indexOf(1)==-1)){  
  94. pageNumbers = [];  
  95. i =((_page.totalPageCount<SIZE)?_page.totalPageCount:SIZE) - 1;  
  96. for ( ; i>=0; i--){  
  97.     pageNumbers.push(_page.totalPageCount-i);  
  98. }  
  99. }  
  100. hListNumbers.selectedItem = _page.currentPageNo;  
  101. }  
  102. protected function btnPrev_clickHandler(event:MouseEvent):void {  
  103.     goPage((hListNumbers.selectedItem as uint) - 1);  
  104. }  
  105. protected function btnNext_clickHandler(event:MouseEvent):void {  
  106.     goPage((hListNumbers.selectedItem as uint) + 1);  
  107. }  
  108. /**  
  109. * 向上分发事件,一般情况下,需要与服务器端通信  
  110. */   
  111. private function goPage(pageNo:uint):void{  
  112.     _page.currentPageNo = pageNo;  
  113.     this.dispatchEvent(new PageEvent(_page, "goPage"));  
  114. }  
  115. protected function hListNumbers_changeHandler(event:ListEvent):void {  
  116.     goPage(hListNumbers.selectedItem as uint);  
  117. }  
  118. protected function lbtnFirst_clickHandler(event:MouseEvent):void {  
  119.     goPage(1);  
  120. }  
  121. protected function lbtnLast_clickHandler(event:MouseEvent):void {  
  122.     goPage(_page.totalPageCount);  
  123. }  
  124. protected function pageSize_changeHandler(event:NumericStepperEvent):void {  
  125. _page.totalPageCount = _page.totalCount / pageSize.value;  
  126. _page.totalPageCount += ((_page.totalCount % pageSize.value)>0)?1:0;  
  127. if (_page.totalPageCount>0){  
  128.     _page.currentPageNo = 1;  
  129.     goPage(_page.currentPageNo);  
  130. }  
  131. }  
  132. protected function btnGo_clickHandler(event:MouseEvent):void {  
  133. var pageNo:int = (Number)(targetPageNo.text);  
  134. if (0==pageNo) {  
  135.     targetPageNo.text = 1 + "";  
  136. }  
  137. if(pageNo<=0){  
  138.     targetPageNo.text = 1 + "";  
  139. }  
  140. if (pageNo>_page.totalPageCount){  
  141.     targetPageNo.text = _page.totalPageCount + "";  
  142. }  
  143. pageNo = (Number)(targetPageNo.text);  
  144. goPage(pageNo);  
  145. }  
  146. ]]>  
  147. </mx:Script>  
  148. <mx:Text text="{page.totalCount+'条记录'}" />  
  149. <mx:Text text="每页"/>  
  150. <mx:NumericStepper id="pageSize"   
  151.   minimum="10" stepSize="5" maximum="5000" value="20"   
  152.   change="pageSize_changeHandler(event)"/>  
  153. <mx:HBox id="hbFirst">  
  154. <mx:LinkButton id="lbtnFirst" label="1..." fontWeight="normal" click="lbtnFirst_clickHandler(event)"/>  
  155. </mx:HBox>  
  156. <mx:HBox id="hbPrev">  
  157.     <mx:Button id="btnPrev" icon="@Embed(source='/assets/prev_page.gif')" enabled="{1!=hListNumbers.selectedItem}" toolTip="上一页" click="btnPrev_clickHandler(event)" cornerRadius="20" alpha="1.0" borderColor="#FDFDFD" width="30"/>  
  158. </mx:HBox>  
  159. <mx:HorizontalList id="hListNumbers" dataProvider="{pageNumbers}"   
  160.   columnCount="10" columnWidth="22"   
  161.   borderStyle="none" backgroundColor="#FFFFFF" height="23"  
  162.   change="hListNumbers_changeHandler(event)">  
  163. </mx:HorizontalList>  
  164. <mx:HBox id="hbNext">  
  165.     <mx:Button id="btnNext" icon="@Embed(source='assets/next_page.gif')" enabled="{page.totalPageCount!=hListNumbers.selectedItem}" toolTip="下一页"    click="btnNext_clickHandler(event)" cornerRadius="20" borderColor="#F9FBFC" width="30"/>  
  166. </mx:HBox>  
  167. <mx:HBox id="hbLast">  
  168.     <mx:LinkButton id="lbtnLast" label="{'...'+page.totalPageCount}" fontWeight="normal" click="lbtnLast_clickHandler(event)"/>  
  169. </mx:HBox>  
  170. <mx:TextInput maxChars="3" restrict="0-9" textAlign="right" id="targetPageNo"/>  
  171. <mx:Button label="Go" cornerRadius="10" width="50" id="btnGo" click="btnGo_clickHandler(event)"/>  
  172. </mx:HBox>  

 

 

4、调用

Actionscript代码
  1. <components:PageBar id= "pageBar"  goPage= "pagedQuery()" />  
  2.   
  3. /**  
  4. * 调用服务器端方法  
  5. */  
  6. private function pagedQuery():void{   
  7.     itemManager.pagedQuery( condition.text, pageBar.page.currentPageNo, pageBar.pageSize.value); }  
  8. }  
  9.    
  10.   
  11. /**  
  12.  * 相应分页查询方法  
  13.  */  
  14. private function onPagedQuery(event:ResultEvent):void{  
  15.     pageBar.page = Page.buildPage(event.result); items = pageBar.page.resultList;  // items为DataGrid的dataProvider  
  16. }  
Actionscript代码  收藏代码
  1. <components:PageBar id="pageBar" goPage="pagedQuery()"/>  
  2.   
  3. /**  
  4. * 调用服务器端方法  
  5. */  
  6. private function pagedQuery():void{   
  7.     itemManager.pagedQuery( condition.text, pageBar.page.currentPageNo, pageBar.pageSize.value); }  
  8. }  
  9.    
  10.   
  11. /**  
  12.  * 相应分页查询方法  
  13.  */  
  14. private function onPagedQuery(event:ResultEvent):void{  
  15.     pageBar.page = Page.buildPage(event.result); items = pageBar.page.resultList;  // items为DataGrid的dataProvider  
  16. }  
posted on 2012-05-03 14:42  星^_^風  阅读(174)  评论(0编辑  收藏  举报