/** * 获得数据库数据 * */ @Action(value="sysList_data_list") public void getSysListDataList(){ List<Map<String,String>> list = new ArrayList<Map<String,String>>(); String hql = " from SysList a where 1=1 "; List<SysList> codeList = sysListService.findAll(hql); for(SysList sysCode : codeList){ //对数据进行重新编码 Map<String,String> map = new HashMap<String,String>();
map.put("Code",String.valueOf(sysCode.getSysId()));//code map.put("Name",sysCode.getSysName()); list.add(map); } writeJson(list); }
//下拉 function initSysIdName(){ var $sysIdName=$("#sysIdName"); $sysIdName.ComboBox({ url: basePath + 'sysList/sysList_data_list.action?sysId='+sysId, param: { categoryCode: "FBLM_NAME" }, id: "Code", text: "Name", height: "100px", description: "==请选择==" }); $sysIdName.bind("change", function () { var value = $(this).attr('data-value');
//这里是将map数组中的CODE字段的值赋给sysId. $("#sysId").val(value); }); }
<th class="formTitle">所属系统:</th> <td class="formValue"> <input id="indexConfigId" type="hidden" name="sysFunction.sysId" /> <div id="IndexName" type="select" name="IndexName" class="ui-select " isvalid="yes" checkexpession="NotNull">
<ul>
</ul>
</div>
</td>
function setForm(){ var indexExplainId = $("#indexExplainId").val(); $.SetForm({ url: basePath +'indexexplain/indexexplain/getEditData.action', param: { "indexExplainId": indexExplainId }, success: function (data) { var indexExplain=data.obj; var indexConfigId = indexExplain.indexConfigId; $("#indexName").ComboBoxSetValue(indexConfigId);
//因为之前在后台里对COMBOBOX{实质是一个list(封装了一个map数组Map(String,String)集合)}的数据进行重新编码,通过code,这里可以setvalue的值 } }); }
/**
* 保存表单
* @returns
*/
function AcceptClick() {
if (!$('#form').Validform()) {
return false;
}
var indexName = $("#indexName").attr('data-value');
$("#indexConfigId").val(indexName);
//这里通过id选择器 前端获取到查询combobox插件,并将插件中的code赋值给了indexConfigId
$.SumitForm({
url: basePath + 'indexexplain/indexexplain/save_or_update.action',
loading: "正在保存数据...",
data:$("#form").serialize(),
success: function () {
$.currentIframe().$("#gridTable").trigger("reloadGrid");
}
});
}
链接: http://blog.csdn.net/qq_29326717/article/details/54582671