如何添加ComboBox到Rally应用程序中的设置齿轮菜单 [英] How to add ComboBox to settings gear menu in Rally app

查看:160
本文介绍了如何添加ComboBox到Rally应用程序中的设置齿轮菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正在开发一个显示缺陷图表的应用程序。该图表将被选中的复选框过滤,用户可以根据自己的需要进行更改。这些复选框位于应用程序的齿轮菜单中设置下。在App.js中,我有一个类似下面的函数:

Currently I'm working on an app that displays a chart of defects. The chart is to be filtered by a selection of checkboxes that the user can change around to fit his / her needs. These checkboxes are located in the gear menu of the app, under 'settings'. In App.js I have a function that looks like this:

getSettingsFields: function() {
    return [
        {
            xtype: 'fieldcontainer',
            fieldLabel: 'States',
            defaultType: 'checkboxfield',
            items: [
                {...}
                ...
            ]
        }
    ];
}



此功能到目前为止运作良好,并显示我离开代码的项目[他们对这个问题不重要]。问题是,现在我想添加一个ComboBox到具有自定义值的同一设置页面。框中应该有[天,周,月,季度]文本,将进一步过滤要在图表中显示的缺陷。我尝试将getSettingsFields函数改为:

This function works perfectly so far and displays the items I left out of the code [they're not important to the question]. The problem is that now I want to add a ComboBox into the same settings page with custom values. The box should have the text [Days, Weeks, Months, Quarters] inside that will further filter which defects to display in the chart. I tried changing the getSettingsFields function to the following:

getSettingsFields: function() {
    var myStore = Ext.create('Ext.data.Store', {
        fields: ['value', 'range'],
        data: [
            {'value':'day', 'range':'Days'}, //test data for ComboBox
            {'value':'week', 'range':'Weeks'}
        ]
    });

    return [
        {
            xtype: 'combobox',
            fieldLabel: 'Date Range',
            store: myStore,
            displayField: 'range',
            valueField: 'value'
        },
        {
            xtype: 'fieldcontainer',
            fieldLabel: 'States',
            defaultType: 'checkboxfield',
            items: [
                {...}
                ...
            ]
        }
    ];
}

现在当我运行应用程序并点击'settings'消失 - 甚至复选框的字段。任何解释为什么这不工作将是非常有帮助的

Now when I run the app and click on the 'settings' button, everything disappears - even the field of checkboxes. Any explanation to why this is not working would be very helpful!

推荐答案

你基本上做的一切正确 - 你刚刚偶然发现了一个非常微妙的bug。底层的问题是,当设置面板尝试克隆设置字段config数组时,由于包含存储,会发生无限递归。以下代码将解决此问题:

You're basically doing everything correctly- you've just stumbled upon a really subtle bug. The underlying issue is that there is an infinite recursion that occurs when the settings panel is attempting to clone the settings field config array due to the inclusion of the store. The following code will work around the issue:

{
    xtype: 'rallycombobox',
    storeConfig: {
        fields: ['value', 'range'],
        data: [
            {'value':'day', 'range':'Days'}, //test data for ComboBox
            {'value':'week', 'range':'Weeks'}
        ]
    },
    storeType: 'Ext.data.Store',
    fieldLabel: 'Date Range',
    displayField: 'range',
    valueField: 'value'
}

它基本上与你所使用的相同,但是使用rallycombobox,并通过storeType和storeConfig传递存储克隆问题。

It's basically the same as what you had but uses the rallycombobox instead and passes in storeType and storeConfig to get around the store cloning problem.

这篇关于如何添加ComboBox到Rally应用程序中的设置齿轮菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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