首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >基于Rally.ui.combobox.ComboBox的奇异荷载行为

基于Rally.ui.combobox.ComboBox的奇异荷载行为
EN

Stack Overflow用户
提问于 2013-07-15 20:37:43
回答 1查看 597关注 0票数 0

对不起,如果之前已经讨论过这个问题--但是我在Rally.ui.combobox.ComboBox中遇到了一些奇怪的负载行为。

这个应用程序所做的(到目前为止)就是这样:

  1. 创建一个Rally.ui.combobox.IterationComboBox
  2. 一旦选择了一个迭代,使用筛选到所选迭代的Rally.ui.combobox.ComboBox模型填充一个UserStory。

在单击UserStory组合框时,我看到了一些奇怪的行为。它最初只显示了少数几个故事(正确地说,那些在选定的迭代中)。

然而,一两分钟后,它重新绘制自己,然后显示我的项目中的所有故事。

JS控制台显示了其中几个错误:

  • Uncaught TypeError: Cannot call method 'getCount' of null
  • Uncaught TypeError: Cannot read property 'loading' of null

我怀疑我做错了什么时间,什么时候的故事组合框准备好。因此,我添加了一个onReady处理程序,但它似乎帮不了什么忙。

有关这种行为的视频如下:

  • http://screencast.com/t/LxoX9qLD

我的代码显示在这里:

代码语言:javascript
复制
<!DOCTYPE html>
<html>
<head>
    <title>CustomApp</title>
    <!--  (c) 2013 Rally Software Development Corp.  All Rights Reserved. -->
    <!--  Build Date: Mon Jul 15 2013 14:23:12 GMT-0600 (Mountain Daylight Time) -->
    <script type="text/javascript" src="https://rally1.rallydev.com/apps/2.0rc1/sdk.js"></script>

    <script type="text/javascript">
        Rally.onReady(function() {

            Ext.define('CustomApp', {
                extend: 'Rally.app.App',
                componentCls: 'app',

                // Stores the Selected Iteration
                selectedIteration: null,

                // Data Store for Stories
                storyStore: null,

                // Stores the Selected Story
                selectedStory: null,

                // Reference to lumenize
                lumenize: null,

                items: [
                    {
                        xtype: 'container',
                        itemId: 'iterationDropdownContainer',
                        columnWidth: 1
                    },
                    {
                        xtype: 'container',
                        itemId: 'storyDropdownContainer',
                        columnWidth: 1
                    },      
                    {
                        xtype: 'container',
                        itemId: 'testResultSummaryContainer',
                        columnWidth: 1
                    }    
                ],

                launch: function() {
                    // Add the iteration dropdown selector
                    this.down("#iterationDropdownContainer").add( {
                        xtype: 'rallyiterationcombobox',
                        itemId : 'iterationSelector',
                        listeners: {
                            select: this._onIterationSelect,
                            scope: this
                        }
                    });

                    // Lumenize
                    this.lumenize = window.parent.Rally.data.lookback.Lumenize; 
                },

                // Callback when an iteration is selected.
                _onIterationSelect : function() {
                    // Store and save the Selected Iteration        
                    var iterationRecord =  this.down('#iterationSelector').getRecord();
                    this.selectedIteration = iterationRecord.data;
                    console.log(iterationRecord);               

                    // Query to get all Stories in Iteration
                    this.storyStore = Ext.create('Rally.data.WsapiDataStore', {
                        model: "User Story",
                        autoLoad: true,
                        fetch: ["ObjectID","Name","Iteration","TestCases"],
                        filters: [
                            {
                                property: 'Iteration.Name',
                                value: this.selectedIteration.Name
                            }
                        ],
                        listeners: {
                            scope : this,
                            load : this._storiesLoaded
                        }
                    }); 
                },

                // Callback when Story Store is loaded
                _storiesLoaded : function(store, data, success) {
                    console.log("_storiesLoaded");
                    console.log(data);

                    if(this.down("#storySelector")) {
                        this.down("#storySelector").destroy();
                    }

                    // Add a story object dropdown selector 
                    this.down("#storyDropdownContainer").add( {
                        xtype: 'rallycombobox',
                        store: this.storyStore,
                        autoLoad: false,
                        disabled: true,
                        itemId : 'storySelector',
                        listeners: {
                            ready: this._storySelectorReady,
                            select: this._onStorySelected,
                            scope: this
                        }
                    }); 
                },

                _storySelectorReady: function(storyCombobox) {
                    storyCombobox.disabled = false;
                },    

                // Callback when a Story has been selected
                _onStorySelected : function() {
                    // Store and save the Selected Iteration        
                    var storyRecord =  this.down('#storySelector').getRecord();
                    this.selectedStory = storyRecord.data;

                    console.log(storyRecord);
                },    

                _showTable : function() {
                    console.log("_showTable");
                }            
            });

           Rally.launchApp('CustomApp', {
               name: 'CustomApp'
           });
        });
    </script>


<link rel="stylesheet" type="text/css" href="src/style/app.css">

</head>
<body></body>
</html>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-06 00:44:01

storyStore正在加载两次,一次是在创建它时,而combobox还告诉它,一旦用户打开combobox来选择一个故事,就再次加载它。因此,您的商店负载侦听器将被调用两次,实际上正在创建两个层的组合框。在Ext的深处,它不喜欢这个。

最简单的解决方法是将single: true添加到商店的侦听器中:

代码语言:javascript
复制
listeners: {
    scope : this,
    load : this._storiesLoaded,
    single: true
}

但是,更好的方法可能是将商店设置为创建故事组合框的一部分:

代码语言:javascript
复制
_onIterationSelect : function() {
  // Store and save the Selected Iteration        
  var iterationRecord =  this.down('#iterationSelector').getRecord();
  this.selectedIteration = iterationRecord.data;
  console.log(iterationRecord);               

  this.down("#storyDropdownContainer").add( {
        xtype: 'rallycombobox',
        itemId : 'storySelector',
        storeConfig: {
            model: 'User Story',
            autoLoad: true,
            filters: [{
                  property: 'Iteration.Name',
                  value: this.selectedIteration.Name
            }]
        },
        listeners: {
             ready: this._storySelectorReady,
             select: this._onStorySelected,
             scope: this
        }
  }); 
},
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17663475

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档