flex分页控件的使用
分页显示数据是网站浏览中必备的元素之一,在FLEX中通过数据分页的方法来获取当前显示数据,即能降低网络传的负担同时也能减少Flex分页显示数据是网站浏览中必备的元素之一,在FLEX中通过数据分页的方法来获取当前显示数据,即能降低网络传的负担同时也能减少Flex的处理工作。
分页控件需要的功能有:首页,,,未页和页数跳转等。
定义分页控件的事件:PageChange
相关事件参数对象:
package
public var PageIndex:int=0;
public var PageSize:int=0;
public function Filter:Array
else
break;
}
return newlist;
}
}
}
分页控件的代码:
<?xml version=1.0 encoding=utf-8?
<mx:Canvas xmlns:mx= width=466 height=40
<mx:Metadata
[Event]
</mx:Metadata
<mx:Button click=method_le id=c_le enabled=false x=10 y=10 fontFamily= width=24 height=24 minWidth=24 minHeight=24
<mx:icon@Embed</mx:icon
</mx:Button
<mx:Button click=method_l id=c_l enabled=false x=42 y=10 fontFamily= width=24 height=24 minWidth=24 minHeight=24
<mx:icon@Embed</mx:icon
</mx:Button
<mx:ComboBox
rowCount=10 change=method_select id=c_select enabled=false
x=74 y=10 width=54</mx:ComboBox
<mx:Button click=method_r id=c_r enabled=false x=136 y=10 fontFamily= width=24 height=24 minWidth=24 minHeight=24
<mx:icon@Embed</mx:icon
</mx:Button
<mx:Button click=method_re id=c_re enabled=false x=168 y=10 fontFamily= width=24 height=24 minWidth=24 minHeight=24
<mx:icon@Embed</mx:icon
</mx:Button
<mx:Script
<![CDATA[
import mx.controls.Alert;
private var mRecordCount:int=0;
private var mPageSize:int =20;
private var mPageIndex:int =0;
private var mPageCount:int = 0;
public function method_l:void
public function method_le:void
public function method_r:void
public function method_re:void
public function method_select:void
public function get PageIndex:int
//设置记录总数
public function set RecordCount:void
}
private function SetState:void
else
var pages:Array = new Array;
for
);
}
c_select.dataProvider= pages;
c_select.selectedIndex= mPageIndex;
if
if
}
else
pageinfo.text=Records: + mRecordCount+/ + mPageCount+pages;
}
//获取记录总数
public function get RecordCount:int
//打开分页控件
public function Open:void
//刷新当前页面
public function Refresh:void
private function OnPageChange:void
]]
</mx:Script
<mx:Label x=200 y=10 width=175 fontSize=12 id=pageinfo/
</mx:Canvas
用例页面代码:
<?xml version=1.0 encoding=utf-8?
<mx:Application initialize=oninit xmlns:mx= layout=vertical xmlns:ns1=Units.* xmlns:ns2=*
<mx:Script
<![CDATA[
import mx.controls.Alert;
import flash.events.Event;
import Units.*;
private var datas:Array = new Array;
function oninit:void
pagebar1.RecordCount =datas.length;
pagebar1.Open;
}
function pagechange:void
]]
</mx:Script
<mx:DataGrid width=100% id=datalist
<mx:columns
<mx:DataGridColumn headerText=UserName dataField=UserName/
<mx:DataGridColumn headerText=Notes dataField=Notes/
</mx:columns
</mx:DataGrid
<ns2:PageBar id=pagebar1 PageChange=pagechange
</ns2:PageBar
</mx:Application