jquery easyui combotree获取值, combotree获取多个值

================================

©Copyright 蕃薯耀 2020-01-06

https://www.cnblogs.com/fanshuyao/

jquery easyui combotree获取多个值是使用getValues方法的,不能使用getValue,只会返回第一个选中的值。

combotree使用getValues返回的是一个数组,包括所有选中的值,但一般只要字符串形式,兼容性好,避免后台接收不了。

/**
 * 获取combotree的值,以字符串形式返回(英文逗号分隔)
 * @param combotreeId combotree id值
 * @returns {String}
 */
function getCombotreeValues(combotreeId){
    var result = "";
    var cmm_code_ids= $("#"+combotreeId).combotree('getValues');
    if(cmm_code_ids.length > 0){
        for(var i=0; i<cmm_code_ids.length; i++){
            result += cmm_code_ids[i] + ",";
        }
        if(result.indexOf(",") > -1){
            result = result.substring(0, result.length - 1)
        }
    }
    return result;
};

(如果你觉得文章对你有帮助,欢迎捐赠,^_^,谢谢!) 

================================

©Copyright 蕃薯耀 2020-01-06

https://www.cnblogs.com/fanshuyao/

原文地址:https://www.cnblogs.com/fanshuyao/p/12156994.html