Ext.js5下拉单选框—查询远程数据(27)

view

/**
 * This example illustrates a combo box which querys a remote data source.
 * 这个例子用来模拟下拉框查找远程数据资源
 */
Ext.define('KitchenSink.view.form.combobox.RemoteQuery', {
    extend: 'Ext.form.Panel',
    xtype: 'remote-combo',


    title: 'Remote Query ComboBox',
    width: 500,
    layout: 'form',
    viewModel: {},

    items: [{
        xtype: 'fieldset',
        layout: 'anchor',
        items: [{
            xtype: 'component',
            anchor: '100%',
            html: [
                '<h3>Remote query mode</h3>',
                '<p>This ComboBox uses <code>queryMode: "remote"</code> ',
                'to perform the query on a remote API which returns states ',
                'that match the typed string.</p>'
            ]
        }, {
            xtype: 'displayfield',
            fieldLabel: 'Selected State',
            bind: '{states.value}'
        }, {
            xtype: 'combobox',
            reference: 'states',
            publishes: 'value',
            fieldLabel: 'Select State',
            displayField: 'state',
            anchor: '-15',
            store: {
                type: 'remote-states'
            },

            // We're forcing the query to run every time by setting minChars to 0 设置minchars为0可以让查询运行
            // (default is 4)
            minChars: 0,
            //store传递键入字符串使用的参数名,当ComboBox配置queryMode: 'remote'时。 如果显示设置为falsy值不会被发送,默认值:Defaults to: "query"
            queryParam: 'q',
            queryMode: 'remote'
        }]
    }]
});

model

Ext.define('KitchenSink.model.State', {
    extend: 'KitchenSink.model.Base',

    fields: [
        'abbr',
        'state',
        'description',
        'country'
    ]
});

store

Ext.define('KitchenSink.store.RemoteStates', {
    extend: 'Ext.data.Store',

    alias: 'store.remote-states',

    model: 'KitchenSink.model.State',

    storeId: 'remote-states',

    proxy: {
        type: 'ajax',
        url: 'resources/data/form/states_remote.php',
        reader: {
            type: 'array',
            rootProperty: 'data'
        }
    }
});
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值