- 注册时间
- 2014-10-11
- 最后登录
- 1970-1-1
- 阅读权限
- 10
- 积分
- 85
- 精华
- 0
- 帖子
- 20
|
gird中有几行数据,并在list_grid列表中添加新的几行,点击保存。此处使用getEditData(true),按预期是list上最新的几行json,但实际显示所有list上的json数据。这是什么问题导致?请大神指点
以下页面代码:
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>节目单列表</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="${ctx}/rs/scripts/miniui/themes/icons.css"/>
<link href="${ctx}/rs/css/demo.css" rel="stylesheet" type="text/css" />
<link href="${ctx}/rs/css/layout.css" rel="stylesheet" type="text/css" />
<link href="${ctx}/rs/css/top.css" rel="stylesheet" type="text/css" />
<link href="${ctx}/rs/css/left.css" rel="stylesheet" type="text/css" />
<link href="${ctx}/rs/css/right.css" rel="stylesheet" type="text/css" />
<link href="${ctx}/rs/css/foot.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="${ctx}/rs/js/sider.js"></script>
<script src="${ctx}/rs/scripts/boot.js" type="text/javascript"></script>
</head>
<body>
<div class="main">
<div class="opo_right_bar" id="right" style="width:100%;">
<div class="mini-toolbar">
<input class="mini-hidden" id="programId" name="programId" value="${programId}"/>
<a class="mini-button" iconCls="icon-add" onclick="newRow">添加</a>
<span class="separator"></span>
<a class="mini-button" iconCls="icon-save" onclick="saveData()" plain="true">保存</a>
</div>
<div class="mini-fit" >
<div id="datagrid" class="mini-datagrid" url="${ctx}/program/page.htm" style="width:100%;height:100%;" idField="id" showFooter="false" allowSortColumn="false">
<div property="columns">
<div type="checkcolumn"></div>
<div field="name" width="120">节目单名称
<input property="editor" class="mini-textbox" style="width:100%;"/>
</div>
<div field="startTime" width="100" align="center" headerAlign="center">开始时间
<input property="editor" class="mini-timespinner" format="HH:mm" style="width: 100%"/>
</div>
<div field="endTime" width="100" align="center" headerAlign="center">结束时间
<input property="editor" class="mini-timespinner" format="HH:mm" style="width: 100%"/>
</div>
<!-- <div field="url" width="100" align="center" headerAlign="center">节目单URL -->
<!-- <input property="editor" class="mini-textbox" style="width:100%;"/> -->
<!-- </div> -->
<div cellCls="actionIcons" name="action" width="40" headerAlign="center" align="center" renderer="onActionRenderer" cellStyle="padding:0;">操作</div>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
mini.parse();
var grid = mini.get("datagrid");
var programId = mini.get("programId").getValue();
grid.load( {
programId :programId
});
function SetData(data){
//跨页面传递的数据对象,克隆后才可以安全使用
data = mini.clone(data);
form.setData(data);
}
function newRow() {
var row = {};
grid.addRow(row);
grid.beginEditRow(row);
}
function delRow(row_uid) {
var row = grid.getRowByUID(row_uid);
if (row) {
if (confirm("确定删除选中记录?")) {
grid.removeRow(row);
//删除数据表
if(row.hasOwnProperty("id")){
var ids = new Array();
ids.push(row.id);
$.ajax({
url: "${ctx}/palaybill/delete.htm?ids=" + ids,
success: function (text) {
grid.reload();
},
error: function () {
}
});
}
}
}
}
function onActionRenderer(e) {
var grid = e.sender;
var record = e.record;
var uid = record._uid;
var rowIndex = e.rowIndex;
var s = '<a class="Edit_Button" href="javascript:delRow(\'' + uid + '\')">删除</a>';
return s;
}
function saveData(){
var data = grid.getEditData(true);
if(data==null||data==''){
alert('暂无保存数据');
return false;
}
var json = mini.encode(data);
alert(json);
// grid.loading("保存中,请稍后......");
// $.ajax({
// url: "${ctx}/palaybill/saveData.htm",
// type: "post",
// data: { programId:programId,data:json},
// success: function (text) {
// alert('保存成功!');
// grid.load({programId :programId});
// },
// error: function (jqXHR, textStatus, errorThrown) {
// alert(jqXHR.responseText);
// }
// });
}
</script>
</body>
</html> |
|