日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

Flex中在DataGrid加載數(shù)據(jù)時(shí)顯示Loading...

系統(tǒng) 2191 0

???? ?網(wǎng)絡(luò)狀況是互聯(lián)網(wǎng)發(fā)展與軟件發(fā)展的一個(gè)很大的瓶頸,如果哪天訪問網(wǎng)上資源能象訪問本地硬盤,或者能象訪問內(nèi)存那樣快,那樣咱們的計(jì)算機(jī)以后只需要輸入輸出設(shè)備以及網(wǎng)絡(luò)設(shè)備就可以了,哈哈,這只是一個(gè)美好的愿望。

???? ?Flex應(yīng)用在Web開發(fā)上,避免不了網(wǎng)絡(luò)問題,下面的說明如何在加載數(shù)據(jù)時(shí)顯示Loading狀態(tài),剛剛接觸Flex不久,歡迎拍磚。

?

????? 原理是這樣的,首先定義了兩一個(gè)ViewState,其中一個(gè)就是Loading狀態(tài),當(dāng)點(diǎn)擊按鈕的時(shí)候就顯示這個(gè)Loading視圖,直到數(shù)據(jù)加載完之顯示數(shù)據(jù)的視圖。?

?

????? 先看效果圖片:

????? 首先,點(diǎn)擊了按鈕之后就會由于網(wǎng)絡(luò)問題顯示一個(gè)遮罩,上面用了一個(gè)Label顯示Loading...字樣,當(dāng)然這里可以用任何更加漂亮的東西替換,比如GIF的圖片。這里的網(wǎng)絡(luò)問題由于是在自己的機(jī)器上測試,是人為造成的,我的服務(wù)器代碼是使用的JAVA,在服務(wù)器上延遲了三秒加載數(shù)據(jù)。

?????

?????

?

三秒之后顯示:

?

??????

?

代碼:

?

    <?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
	<mx:states>
		<!--加載視圖,可以自己制作加載畫面,
		這個(gè)例子就只用了一個(gè)LABEL表示一下正在加載-->
		<!--數(shù)據(jù)加載成功后的State-->
		<mx:State name="ListState">
			<mx:AddChild relativeTo="{pl}" position="lastChild">
				<mx:Canvas id="can" width="100%" height="100%">
					<mx:DataGrid id="dg" horizontalCenter="0" width="100%" height="100%" >
						<mx:columns>
							<mx:DataGridColumn headerText="Id" dataField="p_id"/>
							<mx:DataGridColumn headerText="Title" dataField="p_title"/>
						</mx:columns>
					</mx:DataGrid>
				</mx:Canvas>
			</mx:AddChild>
		</mx:State>
		<!--加載狀態(tài)的視圖-->
		<mx:State name="LoadingState" basedOn="ListState">
			<mx:AddChild relativeTo="{can}" position="lastChild">
				<mx:Canvas id="shade" width="100%" height="100%"
					 backgroundColor="blue" backgroundAlpha="0.1">
					<mx:Label text="Loading..." horizontalCenter="0" verticalCenter="0" fontSize="14"/>
				</mx:Canvas>
			</mx:AddChild>
		</mx:State>
	</mx:states>
	<mx:Script>
		<![CDATA[
			import mx.rpc.AsyncToken;
			public function listLoad() {
				this.currentState = "LoadingState";
				//var loadListResponder:LoadListResponder = new LoadListResponder(this, this.dg);
				//var token:AsyncToken = listLoadService.send();
				//token.addResponder(loadListResponder);
				listLoadService.send();
			}
		]]>
	</mx:Script>
	<mx:HTTPService id="listLoadService"
					url="http://...."
					method="post">
					<mx:result>
						<![CDATA[
							this.dg.dataProvider = listLoadService.lastResult.data.problems.problem;
							this.currentState = "ListState";
						]]>
					</mx:result>
	</mx:HTTPService>
	<mx:Panel id="pl" title="lOAding..." width="400" height="300">
		
	</mx:Panel> 
	<mx:Button x="10" y="333" label="Load Data" click="listLoad()"/>
</mx:Application>

  

?

?

?

參考文章:

?Show Flex Datagrid as busy while loading and reloading

?

問題:

?

I am using showbusycursor on my HTTPService so that while the datagid is loading is that the? cursor at least changes but I would like to do more like graying out the datagrid or something. ?But I am not sure where to start I tried:

?????? ?????<mx:DataGrid dataProvider="{repRoleUsersXLC}" width="100%" height="90%"
?????? ??????????? ?????? ? ? ? ? ? ? ? ?id="AssUsersDG"
?????? ??????????? ?????? ? ? ? ? ? ? ? ?updateComplete="this.enabled=true"
?????? ??????????? ?????? ? ? ? ? ? ? ? ?creationComplete="this.enabled=false"/>

but it didn't do as expected it disabled the scroll bar but I hoped it would disable grid. ?But I would like to do something that is really clear the data grid is loading and reloading thanks for any help.

?

回答:

?

You could use a loading state like I've shown you below, the loading text could be an animation or whatever you choose. In real use you would make this a custom component but to keep things simple I've just made it an app, and I've used a button to simulate the load but you would obviously change your events on the grid to do that instead:

<mx:DataGrid dataProvider="{repRoleUsersXLC}" width="100%" height="90%"
id="AssUsersDG"
updateComplete="currentState=null"
creationComplete="currentState='loading'"/>
<!-- richText -->

?

?

?

????

Flex中在DataGrid加載數(shù)據(jù)時(shí)顯示Loading...


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長非常感激您!手機(jī)微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 九龙县| 乌兰察布市| 洛浦县| 防城港市| 南岸区| 翁源县| 晋中市| 南涧| 越西县| 宁阳县| 丰原市| 海晏县| 浦北县| 长宁区| 海南省| 柳河县| 南丹县| 芷江| 江山市| 南川市| 襄汾县| 东明县| 鄯善县| 闻喜县| 长丰县| 台北市| 讷河市| 滁州市| 新兴县| 阳谷县| 龙井市| 涡阳县| 宜兴市| 林甸县| 霍邱县| 华亭县| 紫金县| 平谷区| 贵定县| 大丰市| 尼木县|