星火Datagrid的滚动 [英] Spark Datagrid scrolling

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

问题描述

我有一个数据(比如用于例如,一百万行)在移动应用程序来显示在DataGrid中。我想弄清楚,只要滚动到达页面即末端的途径,使。网格上的最后一排它再次请求到服务器进行下一堆记录。 滚动事件MX数据网格( HTTP ://blog.tremend.ro/2009/03/02/flex-live-scroll-datagrid/ )做它用轻松,但它不存在火花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..!!

感谢

推荐答案

我也很快编译的工作的例子。您可以添加监听器滚动的DataGrid的 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.
}

完整的code是因为:

The complete code is as:

<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>

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

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