- 注册时间
- 2014-5-24
- 最后登录
- 2015-2-5
- 阅读权限
- 10
- 积分
- 310
- 精华
- 0
- 帖子
- 90
|
felt 发表于 2014-11-20 15:24
请提供能重现问题的简单页面和数据
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page contentType="text/html;charset=utf-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>记账</title>
<script src="${ctx}/js/validation/validation.js"
type="text/javascript"></script>
</head>
<body style="height:98%; width:99%;background:white;">
<div align="center">
<div style="width:800px;" >
<div class="mini-toolbar" style="border-bottom:0;padding:0px;">
<table style="width:100%;">
<tr>
<td style="width:100%;text-align:left">
<input id="memberCode" type="hidden" value="${usession.memberCode }" />
<a class="mini-button" iconCls="icon-add" onclick="addRow()" plain="true" tooltip="增加...">增加</a>
<span class="separator"></span>
</td>
</tr>
</table>
</div>
</div>
<form id="form1">
<div id="datagrid1" class="mini-datagrid" style="width:800px;height:200px;" idField="id"
url="${ctx}/login/loanaccounts!query.action"
allowResize="true" pageSize="20" showFooter="false"
allowCellEdit="true" allowCellSelect="true" multiSelect="true" oncellendedit="checkCourse"
editNextOnEnterKey="true" editNextRowCell="true">
<div property="columns">
<div type="indexcolumn"></div>
<div type="checkcolumn"></div>
<div type="comboboxcolumn" autoShowPopup="true" name="courseType" field="courseType" width="100" align="center" headerAlign="center">
类型
<input property="editor" class="mini-combobox" style="width:100%;" data="Genders" />
</div>
<div name="course" field="course" displayField="courseField" headerAlign="center" width="150" >
科目
<input id="courseId" name="courseId" property="editor" class="mini-buttonedit" width="300px" onbuttonclick="onButtonEdit" />
</div>
</div>
</div>
</form>
</div>
<script type="text/javascript">
mini.parse();
var grid = mini.get("datagrid1");
var form1 = new mini.Form("#form1");
var saveButton = mini.get("saveButton");
var resetButton = mini.get("resetButton");
var key = mini.get("key");
var code = mini.get("code");
var courseOne = mini.get("courseOne");
var courseTwo = mini.get("courseTwo");
var Genders = [{ id: 1, text: '借方' }, { id: 2, text: '贷方'}];
//监听单元格编辑事件
function checkCourse(e){
if(e.field=="course"){
onCourseRenderer(e);
}
}
//列表科目显示
function onCourseRenderer(e) {
var values;
var row = grid.getSelected();
//var renderer = this;
var grid1 = e.sender;
var record = e.record;
var courseField = record.courseField;
// var course = record.course;
if(courseField==null||courseField==""){
return;
}
if(checkloan(courseField)==false) {
grid.updateRow(row,{courseField:""});
return;
}
$.ajax({
url: "${ctx}/login/loancourse!getCourseByCode.action",
data: { oneCourse: courseField},
type: "post",
success: function (text) {
var datajson = text.datajson;
alert(datajson);
if(datajson == '0'){
alert("该凭证不存在");
grid.updateRow(row,{courseField:""});
return;
}else if(datajson == '1'){
alert("总科目不可用");
grid.updateRow(row,{courseField:""});
return;
}else if(datajson == '2'){
alert("本科目下存在多条数据,只能选择一条");
grid.updateRow(row,{courseField:""});
return;
}
else if(datajson == '3'){
grid.cancelEdit();
grid.updateRow(row,{course:text.course,courseField:text.code});
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert(jqXHR.responseText);
}
});
}
//弹出文本框 弹出科目树页面
function onButtonEdit(e) {
var btnEdit = this;
mini.open({
url: "${ctx}/login/loanaccounts!toloancoursetree.action",
title: "多选树",
width: 350,
height: 350,
onload: function () {
var ifr = this.getIFrameEl();
var data = { action: "tree"};
ifr.contentWindow.SetData(data);
},
ondestroy: function (action) {
if (action == "ok") {
var iframe = this.getIFrameEl();
var data = iframe.contentWindow.GetData();
data = mini.clone(data);
btnEdit.setValue(data.text);
btnEdit.setText(data.id);
}
}
});
}
function addRow() {
//获得行数
var count = grid.getData().length;
if(count>5){
alert("最多添加6行数据");
return;
}
var newRow = {};
grid.addRow(newRow);
grid.beginEditCell(newRow);
grid.updateRow(newRow,{course:"",courseField:""});
}
</script>
</body>
</html> |
|