设置成下拉框
{
name: 'ddConditionValueMode', width: "10%", sortable: false,
edittype: "select",
editoptions: {value: selectConditionValueMode()},
formatter: "select",
}
edittype:“select”
editoptions: {value: selectConditionValueMode()},
selectConditionValueMode()方法的返回值格式:key:value;key:value
value是下拉框中显示的值
获得下拉框中的值
function selectConditionValueMode(){
var conditionValueMode = "";
$.ajax({
async: false,
url: BASE_PATH + "/rest/classifyRule/selectConditionValueMode",
type: "GET",
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (resp) {
conditionValueMode += resp.data.data;
}
});
return conditionValueMode;
}
async: false,
return conditionValueMode;
这两个一定要有
后台代码
@RequestMapping(value = "/selectConditionValueMode", method = RequestMethod.GET)
public @ResponseBody String selectConditionValueMode() {
ResultBean resultBean = new ResultBean();
StringBuilder attrTypeBuiler = new StringBuilder();
String attrType = "无";
List<Dictionarydata> datas = dictionaryCommUtil.getDictionarydataList("UBP_EX", "ConditionValueMode");
for (Dictionarydata data : datas) {
String s = data.getDictdatacode() + ":" + data.getDictdataname() + ";";
attrTypeBuiler.append(s);
}
if (attrTypeBuiler.toString().length() != 0) {
attrType = attrTypeBuiler.toString().substring(0, attrTypeBuiler.toString().length() - 1);
}
resultBean.setData(attrType);
return SUCCESS(resultBean);
}
动态改变下拉框中的值
function getCriActionList(rowid) {
console.log(rowid);
$(cri_action_selector).setColProp('classifyActionCode', {editoptions: {value:getClassifyActionName()}});
$(cri_action_selector).jqGrid('setGridParam', {
postData: {fkClassifyRuleItem: rowid, page: 1}
}).trigger("reloadGrid");
}
在重新加载表格时动态设置下拉框中的值
重点是这一句:
$(cri_action_selector).setColProp(‘classifyActionCode’, {editoptions: {value:getClassifyActionName()}});
$(表格名变量).setColProp(‘列名’, {editoptions: {value:获取值的方法}});