easyui 如何获得 combobox 动态赋值后选中的 id.
combobox如下:
然后动态从 springmvc controller 层获得要显示的数据
动态获取 combobox 内容的controller 层部分代码
然后我想获得选中的 id,而不是显示的 name,我采用绑定或者 combobox('getValue')的方式获得的都是显示的name 的值,我该如何获得 id 并传到controller 层呢?是不是代码有什么问题呢?
<input id="dept" class="easyui-combobox" name="department_name" style="width: 220px"
data-options="editable:false,panelHeight:'auto'">然后动态从 springmvc controller 层获得要显示的数据
$(document).ready(function() {
$.ajax({
url : '${pageContext.request.contextPath}/dept/getcombobox',
type : 'post',
valueField : 'id',
textField : 'name',
success : function(data) {
var themecombo = [];
for ( var i = 0; i < data.length; i++) {
themecombo.push({
"id" : data[i].id,
"text" : data[i].name
});
}
$("#dept").combobox("loadData", themecombo);
if (data) {
$('#dept').combobox('setValue', data[0].name);
}
}
});
});动态获取 combobox 内容的controller 层部分代码
@RequestMapping("/getcombobox")
@ResponseBody
public JSONArray getDept(HttpServletRequest request) {
....
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
....
JSONArray jsonArray = JSONArray.fromObject(list);
return jsonArray;
}然后我想获得选中的 id,而不是显示的 name,我采用绑定或者 combobox('getValue')的方式获得的都是显示的name 的值,我该如何获得 id 并传到controller 层呢?是不是代码有什么问题呢?
...全文
相关推荐
EasyUI Combobox设置默认值 获取text的方法
主要介绍了EasyUI Combobox设置默认值 获取text的方法,非常不错,具有参考借鉴价值,需要的朋友可以参考下
在easyui-combobox多选模式下加入选择所有选项
NULL 博文链接:https://wusuobuai.iteye.com/blog/1848724
easyui datagrid 行编辑中combogrid和combobox显示问题
修改上一个资源版本中结束编辑时combobox显示问题. 1、类型为combogrid时每行的参数不同查询返回对应的数据结果。 2、类型为combobox时,输入框显示图标按钮,实现对应的事件。 3、解决类型为combobox显示为value而不是text问题
easyui的datagrid中editor和combobox的级联
easyui的datagrid中editor和combobox的级联,在datagrid中编辑项是下拉框的实现方式
easyui-textbox和easyui-combobox的onchange事件响应实例
这是我自己总结出来easyui-textbox和easyui-combobox的onchange事件响应实例,绝对可用,网上很多实例都无法运行,这个我亲自测试可用使用才传上来的,供大家参考学习。


