package com.wb.controls;

import com.wb.common.KVBuffer;
import com.wb.util.StringUtil;
import com.wb.util.WebUtil;

/**
 * Combo控件的解析类。
 */
public class ExtCombo extends ExtControl {
	protected void extendConfig() throws Exception {
		String keyName = gs("keyName");
		if (!keyName.isEmpty()) {
			if (hasItems)
				headerScript.append(',');
			else
				hasItems = true;
			headerScript.append(getkeyNameScript(keyName));
		}
	}

	/**
	 * 获得键值相关的表达式脚本。
	 * @return
	 */
	public String getkeyNameScript(String keyName) {
		/**
		 * update by yangxh 2021/07/26
		 * 取消keyName下拉按key排序
		 */
		return StringUtil.concat(
				"displayField:\"V\",valueField:\"K\",forceSelection:true,queryMode:\"local\",store:{fields:[\"K\",\"V\"],data:",
				KVBuffer.getList(keyName, WebUtil.fetch(request, "sys.tenancyId")), "}");
		/*return StringUtil.concat(
				"displayField:\"V\",valueField:\"K\",forceSelection:true,queryMode:\"local\",store:{fields:[\"K\",\"V\"],sorters:\"K\",data:",
				KVBuffer.getList(keyName), "}");*/
	}
}
