Ext 4.1.1: 添加新记录到 Store [英] Ext 4.1.1: Add new record to Store

查看:23
本文介绍了Ext 4.1.1: 添加新记录到 Store的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在商店初始化后添加记录.

I would like to add records after the initialization of a store.

我试过 loadData(), loadRawData(), add() 但没什么效果.

I tried loadData(), loadRawData(), add() but nothing seams to work.

这是我的 jsfiddle:http://jsfiddle.net/charlesbourasseau/zVvLc

Here is my jsfiddle: http://jsfiddle.net/charlesbourasseau/zVvLc

有什么想法吗?

推荐答案

您需要在组合框中设置 queryMode: 'local'.最小示例:

You need to set queryMode: 'local' in the combo box. Minimal example:

Ext.onReady(function() {
    var store = Ext.create('Ext.data.Store', {
        alias: 'store.ModeStore',
        autoLoad: false,
        fields: [{
            name: 'mode',
            type: 'string'
        }, {
            name: 'id',
            type: 'string'
        }],
        data: [{
            mode: 'mode1',
            id: 1
        }]
    });

    var container = Ext.create('Ext.form.field.ComboBox', {
        renderTo: Ext.getBody(),
        displayField: 'mode',
        valueField: 'mode',
        store: store,
        queryMode: 'local'
    });

    store.add({
        mode: 'mode2',
        id: 2
    });
}); 

这篇关于Ext 4.1.1: 添加新记录到 Store的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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