亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

Flex中在DataGrid加載數據時顯示Loading...

系統 1940 0

???? ?網絡狀況是互聯網發展與軟件發展的一個很大的瓶頸,如果哪天訪問網上資源能象訪問本地硬盤,或者能象訪問內存那樣快,那樣咱們的計算機以后只需要輸入輸出設備以及網絡設備就可以了,哈哈,這只是一個美好的愿望。

???? ?Flex應用在Web開發上,避免不了網絡問題,下面的說明如何在加載數據時顯示Loading狀態,剛剛接觸Flex不久,歡迎拍磚。

?

????? 原理是這樣的,首先定義了兩一個ViewState,其中一個就是Loading狀態,當點擊按鈕的時候就顯示這個Loading視圖,直到數據加載完之顯示數據的視圖。?

?

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

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

?????

?????

?

三秒之后顯示:

?

??????

?

代碼:

?

    <?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
	<mx:states>
		<!--加載視圖,可以自己制作加載畫面,
		這個例子就只用了一個LABEL表示一下正在加載-->
		<!--數據加載成功后的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>
		<!--加載狀態的視圖-->
		<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加載數據時顯示Loading...


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

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

【本文對您有幫助就好】

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

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 精品区| 在线观看日本一区 | 久久久精品午夜免费不卡 | 天天色综合5 | 95视频在线观看在线分类h片 | 日韩第一页在线 | 亚洲视频污 | 亚洲免费中文字幕 | 九九在线免费视频 | 欧美中文字幕在线观看 | 国产成人免费视频精品一区二区 | 精品在线视频播放 | 成人欧美视频在线看免费 | 五月免费视频 | 深夜免费在线视频 | 四虎影院观看视频 | 鲁丝一区 | 国产一区二区三区不卡观 | 国产精品成人第一区 | 成人午夜天 | 青青久久国产成人免费网站 | 综合久久国产对白 | 日本不卡一区二区三区 | 国产区欧美 | 97免费在线观看 | 视频一区色眯眯视频在线 | 国产一区二区影院 | 九九久久国产精品免费热6 九九久久精品 | 国产91精品高清一区二区三区 | 国精品一区二区三区 | 91啪国自产在线高清观看 | 国产精品视频分类一区 | 亚洲欧洲日韩国产一区二区三区 | 精品视频一二三区 | 亚洲一区二区三区日本久久九 | 婷婷综合国产激情在线 | 日一区二区三区 | 成年人视频黄色 | 简单视频在线播放jdav | 60欧美老妇做爰视频 | 成人免费动作大片黄在线 |