Extnet ExtJs Combobox数据源静态配置

2017-04-13  本文已影响0人  hi句身

背景

技术背景

代码实现

/// 定义一个Combobox 待会要使用的静态数据源 base.js
var VTaxRatioCMB = Ext.create('Ext.data.Store', {
    id: 'VTaxRatioCMB',
    fields: ['value', 'name'],
    data : [
        {"value":0, "name":"0"},
        {"value":0.03, "name":"3%"},
        {"value":0.05, "name":"5%"},
        {"value":0.06,"name":"6%"}, 
        {"value":0.085, "name":"8.5%"},
        {"value":0.11, "name":"11%"},
        {"value":0.13, "name":"13%"},
        {"value":0.17, "name":"17%"}
     ]
  });

//使用到的界面引入上面js文件后, 使用. 测试加载都没有问题.

<ext:ComboBox ID="TaxRatio"  StoreID="VTaxRatioCMB" AutoDataBind="true" ValueField="value"  DisplayField="name" runat="server" FieldLabel="税率/征收率" Editable="false" LabelAlign="Right" AnchorHorizontal="90%" EmptyText="" TabIndex="24" IndicatorText="*" IndicatorCls="Indicator" AllowBlank="false">
                   <CustomConfig>
                   <ext:ConfigItem Name="tooltip" Value="税率/征收率" />
                   </CustomConfig>
                   <Listeners>
                       <Select Handler="
                        ">
                     </Select>
                 </Listeners>
                   </ext:ComboBox>

题外话

var initComboxByValue = function (comb) {
            var value = comb.getValue();
            // 此处value定义的类型需要为Int类型, 不然无法匹配类型

            var record = comb.findRecordByValue(value);
            if (record) {
            comb.setSelectedItems(record);
            } else {
            comb.setValue('');
            }
            
        }
/处理combox数据
        var combs = App.ValueAddedTaxPanel.queryBy(function (item) {
            return item.getXType() == 'combobox';
        });
        Ext.Array.each(combs, function (item) {
            initComboxByValue(item);
        });
上一篇 下一篇

猜你喜欢

热点阅读