1. 程式人生 > >035 工作單快速錄入 - bos

035 工作單快速錄入 - bos

rda ring {} 電子 win too pub char html

一、前臺代碼理解及修改

1.新增行也可完成提交原來編輯的行功能(如果有在編輯的行)

//全局變量
var editIndex;

function doAdd() {
if (editIndex != undefined) {
//表示有一行正在編輯,先結束編輯的行(會觸發onAfterEdit)
$("#grid").datagrid(‘endEdit‘, editIndex);
}
//沒有行在編輯狀態才能進行新增
if (editIndex == undefined) {
//alert("快速添加電子單...");
$("#grid").datagrid(‘insertRow‘, {
index : 0,
row : {}
});
$("#grid").datagrid(‘beginEdit‘, 0);
editIndex = 0;
}
}

2.數據表格

// 收派標準數據表格
$(‘#grid‘).datagrid({
iconCls : ‘icon-forward‘,
fit : true,
border : true,
rownumbers : true,
striped : true,
pageList : [ 30, 50, 100 ],
pagination : true,
toolbar : toolbar,
url : "",
idField : ‘id‘,
columns : columns,
onDblClickRow : doDblClickRow,
onAfterEdit : function(rowIndex, rowData, changes) {
console.info(rowData);
//編輯完畢,重置editIndex表示沒有行在編輯
editIndex = undefined;
$.post("workordermanagerAction_add.action", rowData, function(data){

});
}
});

二、服務端實現

1.WorkordermanageAction.add實現

public String add() throws IOException{
String f = "1";
try {
workordermanagerService.save(model);
} catch (Exception e) {
f = "0";
}
ServletActionContext.getResponse().setContentType("text/html;charset=utf-8");
ServletActionContext.getResponse().getWriter().write(f);
return NONE;
}

2.WorkordermanagerServiceImpl.save實現

@Override
public void save(Workordermanager model) {
workordermanagerDao.save(model);
}

035 工作單快速錄入 - bos