datagrid框架
<div id="datagrid1" dataField="data" class="nui-datagrid" style="width: 100%; height: 100%;" url="<%=request.getContextPath()%>/syzcdDksqxxb/queryShow.do?show=spList"
pageSize="10" multiSelect="true" allowSortColumn="false" onselectionchanged="selectionChanged">
后台接收page对象
@ResponseBody
@RequestMapping(value = "/queryShow", method = RequestMethod.POST)
public Map<String, Object> queryShow(HttpServletRequest request, SyzcdDksqxxbVO vo, Pagination page) {
datagrid框架
<div id="datagrid1" dataField="data" class="nui-datagrid" style="width: 100%; height: 100%;" url="<%=request.getContextPath()%>/syzcdDksqxxb/queryShow.do?show=spList"
pageSize="10" multiSelect="true" allowSortColumn="false" onselectionchanged="selectionChanged">
form表单
<div id="form1" class="nui-form" align="left">
<input class="nui-textbox" name="allotnotesid" value="<%=notesid %>" visible="false"></input>
<table id="table1" class="table">
<tr>
<td class="form_label">项目ID:</td>
<td colspan="1">
<input class="nui-textbox" name="projectid" visible="true"> </input>
</td>
</tr>
<td class="form_label" colspan="2" align="center">
<a class="nui-button" iconCls="icon-search" onclick="search()"> 查询 </a>
<a class="nui-button" iconCls="icon-reload" onclick="reset()"> 重置 </a>
</td>
</tr>
</table>
</div>
取得form表单json对象,grid对象加载数据,
<%-- 查询 --%>
function search() {
grid.load(form.getData());
}
后台使用对应的数据模型实体类接收,只能使用post提交
@ResponseBody
@RequestMapping(value = "/queryShow", method = RequestMethod.POST)
public Map<String, Object> queryShow(HttpServletRequest request, SyzcdDksqxxbVO vo, Pagination page) {
使用ajax传递json
$J.postByAjax({
'projectid' : infos.projectid,
'planitemid' : infos.planitemid,
}, "syzcdDksqxxb/getSyzcdDksqxxbVOById.do", ajaxConf);
后台使用对应的数据模型实体类接收
@ResponseBody
public SyzcdDksqxxbVO getSyzcdDksqxxbVOById(SyzcdDksqxxbVO vo) {
ajax可以传递json、string、int等
/* 退回 */
function vback(datastr) {
$J.cap4jConfirm("确定退回此条项目?", "退回提示", function(action) {
if (action == 'ok') {
var dataArr = datastr.split(",");
var ajaxConf = new Cap4jAjaxConf();
ajaxConf.setSuccessFunc(refresh);
ajaxConf.setIsShowSuccMsg(false);
var params = {
"projectid" : dataArr[0],
"planitemid" : dataArr[1],
"supplierid" : dataArr[2]
};
var params = $J.encode(params);//将参数转换为json字符串
$J.postByAjax({
"params" : params
}, appContext + "/syzcdDksqxxb/conter.do?option=back", ajaxConf);
}
});
}
json数据也可以使用request来获取
public void conter(HttpServletRequest request, SyzcdDksqxxbVO vo) {
String params = request.getParameter("params");
String op = request.getParameter("option");
返回数据
List<SyzcdDksqxxbVO> list = iSyzcdDksqxxbService.queryShow(vo); Map<String, Object> map = new HashMap<String, Object>(); int loanNum = 0; for (SyzcdDksqxxbVO syzcdDksqxxbVO : list) { String confirmamount = syzcdDksqxxbVO.getConfirmamount(); if (StringUtils.isNotBlank(confirmamount)) { loanNum += Integer.valueOf(confirmamount); } } map.put("total", list.size() ); map.put("loanNum", loanNum); return map;
使用json接收方式
var ajaxConf = new Cap4jAjaxConf(); ajaxConf.setIsShowSuccMsg(false); ajaxConf.setSuccessFunc(function(result) { console.info(result); $J.getbyName("total").setValue(result.total); $J.getbyName("loanNum").setValue(result.loanNum); }) $J.postByAjax(data, appContext + "/syzcdDksqxxb/queryShow.do?show=total", ajaxConf); }
传递json,其实“”可以省略如:pageType
//录入
function enter(datastr) {
var dataArr = datastr.split(",");
var urlStr = appContext + "/syzcdDksqxxb/show.do?show=spList";
var bizData = {
pageType : "edit",
"projectid" : dataArr[0],
"planitemid" : dataArr[1],
"supplierid" : dataArr[2]
}
$J.showmodaldialog("审批录入", urlStr, 350, 200, bizData, function(action) {
grid.reload();
});
}
返回页面路径,这里request只能取得url拼接的参数,不能取得bizadta中的参数
@FunctionDesc("dksq编辑页面统一调配")
public String show(HttpServletRequest request, Model model) {
Mean(model);
String show = request.getParameter("show");
switch (show) {
case "spList" :
logger.info("syfh_zcd/dksp/SyzcdDksqSpForm");
return "syfh_zcd/dksp/SyzcdDksqSpForm";
default :
return "";
}
}
跨页面数据获取,
<%-- 获取父页面传递来的json数据 --%>
function setData(data) {
var infos = $J.clone(data);
$J.getbyName("pageType").setValue(infos.pageType);
注意这里返回的数据只能在子页面中操作
父页面
回调刷新
$J.showmodaldialog("授信结果录入", appContext + "/syzcdDksqxxb/show.do?show=fkList", 350, 250, bizParams, function(data) { refresh(); });
返回数据
if ("0".equals(json.getJSONObject("ResultHeader").getString("type"))) { update(vo); return 0; } else { return jsonStr; }
子页面
if (show == "fkList") { urlStr = "syzcdDksqxxb/conter.do?option=enterAND" + show; } var ajaxConf = new Cap4jAjaxConf(); ajaxConf.setSuccessFunc(function(data) { if (data) { $J.cap4jAlert(data); } else { CloseWindow(); } }); ajaxConf.setIsShowSuccMsg(false); $J.submitForm("dataform1", urlStr, ajaxConf);