model-view-controller - ExtJS 4 MVC ComboBox 通过 Direct Store 加载 - 单击组合框时如何防止加载?

标签 model-view-controller extjs combobox store

我在 View 中有一个组合框,该组合框绑定(bind)到使用 Ext.Direct 为下拉列表加载数据的数据存储/模型。

在我打开包含组合框的 View 的 Controller 中,我开始加载商店。

一切正常,但是当我单击组合框时,它会启动另一次加载(通过加载屏蔽屏幕)并重新加载商店。我需要阻止第二次加载,因为它已经在加载了。

商店:

Ext.define('ESDB.store.Employees', {
    extend: 'Ext.data.Store',
    model: 'ESDB.model.Employee',
    autoLoad:false,
    proxy: {
        type: 'direct',
        api: {
            create  : undefined,
            read    : EmployeeService.getRecords,
            update  : EmployeeService.setRecord,
            destroy : undefined
        }

    }
});

型号:

Ext.define('ESDB.model.Employee', {
    extend: 'Ext.data.Model',
    fields: ['id','name','login','pw','domain','lastLogin','addedDate','active','ulevel','staffID']
});

查看:

(相关部分 - 组合框 - View 中没有对商店或模型的其他引用)

this.items = [
                {
                xtype: 'form',
                items: [
{
                        xtype: 'combobox',
                        name : 'callTakenBy',
                        fieldLabel: 'Taken By',
                        displayField: 'name',
                        queryMode: 'remote',
                        valueField: 'id',
                        store: "Employees",
                        editable: false
                    }
]]}

Controller (当他们双击网格中的一行时,它会启动员工商店的负载,然后打开 View ):

encounterRowClicked: function(grid, record) {
            console.log('Double clicked on ' + record.get('id'));

            var store = this.getEmployeesStore();
                store.load({
                    params: {
                    },
                    callback: function(r,options,success) {  } //callback
                }); //store.load


            // load the view:

            var view = Ext.widget('encounteredit');
            view.down('form').loadRecord(record);

        }

所有这些代码都有效,但是当我进入 View 时,组合框正确显示了一个加载的值,我单击组合框,它启动了商店的另一次加载。它有效,但我必须再次单击才能实际选择不同的值。所以我正在寻找一种方法来告诉组合框简单地使用商店,而不是加载它——似乎它应该已经知道它已加载并简单地使用它?

最佳答案

您需要为组合框设置 queryMode : 'local'。正如您在文档中看到的那样,默认值为 remote (顺便说一句,你应该删除模式:'remote',模式不是组合框的有效配置)。

在 queryMode: 'remote' 中,ComboBox 根据用户交互动态加载其 Store。

您应该使用“本地”,因为您已经在商店中本地化了数据

关于model-view-controller - ExtJS 4 MVC ComboBox 通过 Direct Store 加载 - 单击组合框时如何防止加载?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8301346/

相关文章:

php - 如何将子域合并到 MVC 框架中

extjs - 将 Ext.Button 添加到 ExtJS columnmodel

javascript - EXTJS范围问题

python - 如何清除 ttk.Combobox 的文本字段部分?

c# - DataGridViewComboBoxCell : How to set selected value when adding a row?

php - 是否反对使用变量在另一个 View 中调用 View 的 MVC 模式?

python - 使用 python 的桌面 GUI 中的 MVC 模式

javascript - 使用 ANGULAR JS 和 Spring MVC 在 HTML 中动态显示添加/删除操作的结果

javascript - 在启用分页的情况下记住 ExtJS 网格中的选择

c# - Winform 上的 C# ComboBox 是否有更新前