简体   繁体   English

如何获取组合框ext js中的大写值项?

[英]how to get the uppercase value items in the combo box ext js?

How to populate the combo box with uppercase value items for the below: Thank you 如何用下面的大写值项填充组合框:谢谢

I have below code 1 and store in the view calling web api as in store reader in code 2 : 我有以下代码1并存储在调用Web api的视图中,如代码2中的store reader所示:

Code 1 : 代码1:

comboBox.store.load({
    callback: function () {
        comboBox.setValue(params.val)
    }
});

Code 2 : 代码2:

Ext.define('App.View.Value', {
    extend: 'Ext.form.field.ComboBox',
    alias: 'widget.App-View-Value',
    labelAlign: 'right',
    emptyText: 'Value',
    valueField: 'Id',
    displayField: 'Name',
    forceSelection: true,
    allowBlank: false,
    editable: false,
    triggerAction: 'all',
    lastQuery:'',
    store: {
        type: 'webapi',
        autoLoad: false,
        api: {
            read: 'api/filter/getVal'
        }
    }
});

If params.val is a String you can do a UpperCase transformation with .toUpperCase() like this 如果params.val是字符串,则可以使用.toUpperCase()这样进行UpperCase转换

comboBox.store.load({
    callback: function () {
        comboBox.setValue(params.val.toUpperCase())
    }
});

You can do it by iterating over records in store's callback function. 您可以通过遍历商店的回调函数中的记录来做到这一点。

Code snippet: 程式码片段:

comboBox.store.load({
    callback: function (records, operation, success) {
        records.forEach(function (rec, index) {
            rec.set('Name', rec.get('Name').toUpperCase());
        })
    }
});

Working Example 工作实例

Hope this will help/guide you. 希望这会对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM