AdvancedDataGrid 中的 Flex 执行超时

发布于 2024-09-29 18:42:15 字数 130 浏览 5 评论 0原文

我有一个问题,我正在使用 AdvancedDataGrid 。

它加载约 3000 条记录,约 20 列。我经常遇到 Flex 执行超时的情况,因为网格在 LayoutManager 内执行了很多操作。 我怎样才能使它异步或更快?

I've a problem, I'm using an AdvancedDataGrid .

It loads about 3000 records with about 20 columns. I constantly get Flex execution timeout because the grid executes a lot inside LayoutManager.
How can I make it asyncronousely or faster at all?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

吖咩 2024-10-06 18:42:15

使用数据网格分页。

http://gurufaction.blogspot.com/2007/02 /flex-datagrid-paging-example-with.html
http://stackoverflow.com/questions/1893350/how-does-flex-3-datagrid-paging-work

或类似的东西

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="InitApp()" xmlns:MyComp="*">
<mx:Script>
    <![CDATA[
        import mx.collections.ArrayCollection;
        import mx.events.ItemClickEvent;
        [Bindable]
        public var myData:ArrayCollection = new ArrayCollection();
        public var orgData:ArrayCollection = new ArrayCollection();
        [Bindable]
        public var nav:ArrayCollection = new ArrayCollection();
        private var index:int = 0;
        private var page:int = 25;      
        private var paging:Boolean = true;

        private function InitApp():void {
            for( var x:uint = 1; x <= 500; x++ ) {
                var obj:Object = new Object();
                obj.Id = x.toString();
                obj.Name = "Column " + x.toString();
                obj.Street = "5555 Street";
                obj.Title = "CEO";
                obj.City = "El Paso";
                orgData.addItem(obj);
            }
            refreshDataProvider(0);
        }

        private function navPage(d:int):void {
            index += d;
            refreshDataProvider(index); 
        }

        private function refreshDataProvider(start:int):void {
            if (paging == true) {
                page = 25;
                myData = new ArrayCollection(orgData.source.slice(start,start+page));
            }
            else {
            index = 0;
                page = 500;
                myData = new ArrayCollection(orgData.source);               
            }
            down.enabled = index > 0;
            up.enabled = index + page < orgData.length;
            lbl.text = index.toString() + ' to ' + (index + page).toString() + ' of ' + orgData.length;             
        }

        private function togglePaging():void {
            paging = !paging;
            toggle.label = paging.toString();
            refreshDataProvider(index);
        }

]]>
</mx:Script>
    <mx:DataGrid id="dg" dataProvider="{myData}" width="510" height="202"></mx:DataGrid>
    <mx:Button x="10" y="210" label="<" click="navPage(-25);" id="down"/>
    <mx:Button x="216" y="210" label=">" click="navPage(25);" id="up"/>
    <mx:Label x="58" y="212" text="page" width="150" id="lbl"/>
    <mx:Button x="264" y="210" label="true" id="toggle" click="togglePaging();"/>

</mx:Application>

Use Datagrid pagination.

http://gurufaction.blogspot.com/2007/02/flex-datagrid-paging-example-with.html
http://stackoverflow.com/questions/1893350/how-does-flex-3-datagrid-paging-work

or something like this

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="InitApp()" xmlns:MyComp="*">
<mx:Script>
    <![CDATA[
        import mx.collections.ArrayCollection;
        import mx.events.ItemClickEvent;
        [Bindable]
        public var myData:ArrayCollection = new ArrayCollection();
        public var orgData:ArrayCollection = new ArrayCollection();
        [Bindable]
        public var nav:ArrayCollection = new ArrayCollection();
        private var index:int = 0;
        private var page:int = 25;      
        private var paging:Boolean = true;

        private function InitApp():void {
            for( var x:uint = 1; x <= 500; x++ ) {
                var obj:Object = new Object();
                obj.Id = x.toString();
                obj.Name = "Column " + x.toString();
                obj.Street = "5555 Street";
                obj.Title = "CEO";
                obj.City = "El Paso";
                orgData.addItem(obj);
            }
            refreshDataProvider(0);
        }

        private function navPage(d:int):void {
            index += d;
            refreshDataProvider(index); 
        }

        private function refreshDataProvider(start:int):void {
            if (paging == true) {
                page = 25;
                myData = new ArrayCollection(orgData.source.slice(start,start+page));
            }
            else {
            index = 0;
                page = 500;
                myData = new ArrayCollection(orgData.source);               
            }
            down.enabled = index > 0;
            up.enabled = index + page < orgData.length;
            lbl.text = index.toString() + ' to ' + (index + page).toString() + ' of ' + orgData.length;             
        }

        private function togglePaging():void {
            paging = !paging;
            toggle.label = paging.toString();
            refreshDataProvider(index);
        }

]]>
</mx:Script>
    <mx:DataGrid id="dg" dataProvider="{myData}" width="510" height="202"></mx:DataGrid>
    <mx:Button x="10" y="210" label="<" click="navPage(-25);" id="down"/>
    <mx:Button x="216" y="210" label=">" click="navPage(25);" id="up"/>
    <mx:Label x="58" y="212" text="page" width="150" id="lbl"/>
    <mx:Button x="264" y="210" label="true" id="toggle" click="togglePaging();"/>

</mx:Application>
软糯酥胸 2024-10-06 18:42:15

一次加载一块数据?比视觉上显示的行数稍多一些。这样您就可以快速获得感知到的性能。

不得不说,一次性加载 3000 条记录是很多...

Load the data a chunk at a time? Say slightly more than however many rows are shown visually. That way you get the perceived performance that it renders quickly.

3000 records is a lot to be loading in one go it has to be said...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文