获取从视图到控制器的值组合框 extJ

Get Value Combobox ExtJs From View to Controller

本文关键字:组合 extJ 控制器 视图 获取      更新时间:2023-09-26
我不知道

ho在ExtJs中从视图到控制器获取值。 也许有人知道ho to.. 在这里帮助我..
这是我的看法Order_v2.js

formSelectProduct: function(seq, name) {
        var panel = {
            id: 'card-' + seq,
            name: name,
            bodyPadding: 10,
            items: [{
                xtype: 'label',
                html: '<h1>Anda mengklik lokasi instalasi.'
            }, {
                xtype: 'combobox',
                fieldLabel: 'Produk',
                store: 'Products',
                name: 'productId',
                mode: 'queryMode',
                displayField: 'productName',
                valueField: 'productValue',
                typeAhead: true,
                forceSelection: true,
                emptyText: 'Pilih Produk...',
                width: 350,
                labelWidth:90,
                id: 'pilih',
                triggerAction: 'all',
                margin: '10 0 0 0',
                value: '4',
                hidden: true
            },
{
                xtype: 'button',
                text: 'Check Feasibility',
                action: 'doFeasibility',
                margin: '10 0 0 0'
            }

我想从组合框中获取值,并在单击按钮时在警报中显示它。 我在控制器中制作了函数。
这是控制器

 refs: [
        { ref: 'formSelectProduct', selector: 'cmsorder > container[name=orderPanel] > form[name=formSelectProduct]' },
.......
this.control({
            'cmsorder > toolbar[name=statusBar] > button[action=doCancel]': {
                click: this.doCancel
            },
            'cmsorder > container > form[name=formSelectProduct] > button[action=doFeasibility]': {
                click: this.doFeasibility
            },
.......
doFeasibility: function() {
var me=this,
         formSelectProduct =me.getFormSelectProduct();
        var combo=formSelectProduct.down('combobox[name=productId]');
        var a=combo.getValue();
        Ext.Msg.alert("Produk yang anda Pilih",a);
    },

RESUT只显示警报而不显示组合框值..有人可以帮助我修复它吗?

我认为这应该有效..

var a=combo[0].getValue();

在我看来,".down"方法是查询方法,它返回带有匹配选择器的 Ext 组件数组。因此,需要索引才能获取组合框的值。

试试这个它会起作用。使用来自 EXT/DOM 的组件/元素的 ID,它提供了从任何地方访问任何元素的功能。Ext.getCmp() 有助于根据分配给组件的 id 搜索元素。

var combo=Ext.getCmp('pilih'); var a=combo.getValue(); Ext.Msg.alert("Produk yang anda Pilih",a);