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

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

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

©Copyright 蕃薯耀 2018年6月26日

http://fanshuyao.iteye.com/

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 蕃薯耀 2018年6月26日

http://fanshuyao.iteye.com/

猜你喜欢

转载自fanshuyao.iteye.com/blog/2425603