package com.wb.controls;

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

/**
 * 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 static String getkeyNameScript(String keyName) {
		return StringUtil.concat(
				"displayField:\"V\",valueField:\"K\",forceSelection:true,queryMode:\"local\",store:{fields:[\"K\",\"V\"],sorters:\"K\",data:",
				KVBuffer.getList(keyName), "}");
	}
}
