zoukankan      html  css  js  c++  java
  • EasyUI combobox动态增加选择项

     有需求需要动态的为combobox增加可选项,后来解决方案如下

    html如下

    <select id="workerList"></select>

    js 如下

     keyArray为数组 tips:此处forEach 不是都支持,火狐官网上有对此方法的修正现在直接将代码贴上,大家可以自行查阅

    if (!Array.prototype.forEach) {  
                Array.prototype.forEach = function(callback, thisArg) {  
                    var T, k;  
                    if (this == null) {  
                        throw new TypeError(" this is null or not defined");  
                    }  
                    var O = Object(this);  
                    var len = O.length >>> 0; // Hack to convert O.length to a UInt32  
                    if ({}.toString.call(callback) != "[object Function]") {  
                        throw new TypeError(callback + " is not a function");  
                    }  
                    if (thisArg) {  
                        T = thisArg;  
                    }  
                    k = 0;  
                    while (k < len) {  
                        var kValue;  
                        if (k in O) {  
                            kValue = O[k];  
                            callback.call(T, kValue, k, O);  
                        }  
                        k++;  
                    }  
                };  
            } 
     keyArray.forEach(function(x){
                                    $("#workerList").append("<option value=""+x+"">"+x+"</option>");
                                })
    $("#workerList").combobox(
                        {
                            editable:false,    
    panelHeight:'auto', onSelect:function(param){ selectChange(param) } });
  • 相关阅读:
    Record
    Solution -「洛谷 P6287」「COCI 2016-2017」Mag
    Solution -「洛谷 P3773」「CTSC 2017」吉夫特
    Solution -「SP 106」BINSTIRL
    Record
    Record
    Record
    Solution Set -「CSP-S 2020」
    MDK在SRAM中运行-STM32F103RCT6为例
    STM8S103F3P STVD+COSMIC开发环境搭建
  • 原文地址:https://www.cnblogs.com/EncryptingLife/p/4675702.html
Copyright © 2011-2022 走看看