Spark Datagrid 滚动 [英] Spark Datagrid scrolling

查看:27
本文介绍了Spark Datagrid 滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据(比如一百万行)要显示在移动应用程序的数据网格中.我试图找出一种方法,一旦滚动到达页面末尾即.网格上的最后一行再次向服务器请求下一组记录.MX 数据网格中的 Scroll 事件 (http://blog.tremend.ro/2009/03/02/flex-live-scroll-datagrid/) 很容易做到,但它不在火花数据网格中.我希望这可以通过 spark datagrid 来完成.

I have a data(say for eg. a million rows) to be displayed in a datagrid in a mobile application. I am trying to figure out a way by which as soon as the scroll reaches the end of page ie. the last row on the grid it requests again to the server for next bunch of records. Scroll event in MX datagrid (http://blog.tremend.ro/2009/03/02/flex-live-scroll-datagrid/) does it with ease but it's not there in spark datagrid. I want this to be done with spark datagrid.

我怎样才能做到这一点.需要帮助..!!

How can i achieve this. Require help..!!

谢谢

推荐答案

我已经快速编译了一个有效的示例.您可以将侦听器添加到数据网格 dg 的滚动条中:

I have quickly compiled an example that works. You can add the listener to scrollbar of datagrid dg as:

dg.scroller.verticalScrollBar.addEventListener(Event.CHANGE, list_verticalScrollBar_change);
private function list_verticalScrollBar_change(evt:Event):void {
            var vsb:VScrollBar = evt.currentTarget as VScrollBar;
            // Now you can check for scroll position.
}

完整代码如下:

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
               creationComplete="application1_creationCompleteHandler(event)">
    <fx:Script>
        <![CDATA[
            import mx.controls.Alert;
            import mx.events.FlexEvent;

            import spark.components.VScrollBar;

            protected function application1_creationCompleteHandler(event:FlexEvent):void
            {
                dg.scroller.verticalScrollBar.addEventListener(Event.CHANGE, list_verticalScrollBar_change)
            }

            private function list_verticalScrollBar_change(evt:Event):void {
                var vsb:VScrollBar = evt.currentTarget as VScrollBar;
                if(dg.grid.contentHeight == dg.grid.layout.verticalScrollPosition+dg.grid.height) {
                    Alert.show("Making service call");
                    // make some service call.
                }
            }

        ]]>
    </fx:Script>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:DataGrid id="dg" width="100%" height="100">
        <s:dataProvider>
            <s:ArrayList> 
                <fx:Object age="24" sex="f" name="Susan" joinDate="{new Date(2007, 5, 15)}" />
                <fx:Object age="36" sex="f" name="Ashley" joinDate="{new Date(1998, 7, 20)}" />
                <fx:Object age="24" sex="f" name="Jennifer" joinDate="{new Date(2001, 3, 24)}" />
                <fx:Object age="19" sex="f" name="Emma" joinDate="{new Date(2002, 3, 24)}" />
                <fx:Object age="44" sex="f" name="Carol" joinDate="{new Date(1999, 9, 16)}" />
                <fx:Object age="28" sex="m" name="Peter" joinDate="{new Date(2005, 3, 12)}" />
                <fx:Object age="35" sex="m" name="Mike" joinDate="{new Date(2008, 10, 10)}" />
                <fx:Object age="26" sex="m" name="Dave" joinDate="{new Date(2008, 10, 10)}" />
                <fx:Object age="44" sex="m" name="William" joinDate="{new Date(2004, 9, 16)}" />
                <fx:Object age="24" sex="m" name="Sean" joinDate="{new Date(2006, 3, 24)}" />
            </s:ArrayList> 
        </s:dataProvider>
    </s:DataGrid>
</s:Application>

这篇关于Spark Datagrid 滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆