- 注册时间
- 2016-9-20
- 最后登录
- 1970-1-1
- 阅读权限
- 10
- 积分
- 25
- 精华
- 0
- 帖子
- 4
|
页面监视了单元格编辑过后状态下拉框StatuDDL的空选项就没用了 尽管能显示<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Manage.aspx.cs" Inherits="Manage" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<script src="Scripts/boot.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div>
<!--管理者-->
所有员工
<input id="StaffDDL" class="mini-combobox" style="width: 150px;" emptytext="查看全部" shownullitem="true" nullitemtext="查看全部" textfield="LoginName" url="AJAX/a.aspx?type=GetAllStaff" valuefield="LoginName" onvaluechanged="staffDDLChanged"/>
<input id="RemarksDDL" class="mini-combobox" style="width: 150px;" emptytext="查看全部" shownullitem="true" nullitemtext="查看全部" textfield="REMARKS" valuefield="ID" onvaluechanged="RemarksDDLChanged"/>
<input id="StatuDDL" class="mini-combobox" style="width: 150px;" emptytext="查看全部" shownullitem="true" nullitemtext="查看全部" data="Status" onvaluechanged="StatuDDLChanged"/>
</div>
<div id="btnS">
<a class="mini-button" iconCls="icon-save" plain="true">保存</a>
<a class="mini-button" iconCls="icon-save" plain="true">取消</a>
</div>
<div id="searchList" allowResize="true" class="mini-datagrid" style="width:700px;height:500px;" url = "AJAX/a.aspx?type=Search"
idField="ID" sizeList="[4,5,10,20,30,50,100]" pageSize="20" multiSelect="true" allowCellEdit="true" allowCellSelect="true">
<div property="columns">
<div type="indexcolumn"></div>
<!--<div type="checkcolumn" ></div> 这个好像会影响到监听获取数据 -->
<div field="ID" width="30" headerAlign="center" allowSort="true">ID</div>
<div field="REMARKS" width="120" headerAlign="center" allowSort="true">详情</div>
<div field="Status" width="120" headerAlign="center" renderer="onStatusRenderer" allowSort="true">状态
<input property="editor" class="mini-combobox" style="width:100%;" data="Status" /><!--data=这种方法赋予数据源好像只能在mini-combobox这类需要json列表的数据上而不能用于对现实数据进行处理 property="editor" 好像是用于标识它是编辑模式-->
</div>
<div field="UID" width="120" headerAlign="center" allowSort="true">UID</div>
<div field="CreateDate" width="150" headerAlign="center" dateFormat="yyyy-MM-dd HH:mm:ss" allowSort="true">添加时间</div>
</div>
</div>
<div class="menu_ul" style="float:left;cursor:pointer;">
<%foreach (var item in p())
{%>
<h2 id="li_<%= item.id %>"><%= item.text%></h2>
<ul>
<%foreach (var d in p(item.id))
{%>
<li><a id="a_<%=d.id %>" href="<%=d.src %>.aspx" target="mainframe"><%=d.text %></a></li><!--target根据name找到了iframe-->
<%
} %>
</ul>
<%
} %>
</ul>
</div>
<div style="float:left;margin:10px;" align="center">
<iframe id="mainframe" frameborder="0" name="mainframe" style="width: 100%; height: 100%; background:url(../CSS/images/题库管理系统-插画.png) no-repeat;float:left;"></iframe>
</div>
</form>
<script>
var Status = [{ id: 1, text: '待审核' }, { id: 2, text: '通过' }, { id: 3, text: '不通过' }];
var uid = "";//记录上次查询哪个员工
var type = "";//记录上次执行哪种查询
$('#RemarksDDL, #searchList, #btnS, #StatuDDL, .menu_ul>h2+ul').hide();
function Unfold(id) {//展开或隐藏ul
if ($('#li_' + id + "+ul").is(":hidden"))
$('.menu_ul>h2+ul').hide();
$('#li_' + id + "+ul").toggle();
}
mini.parse();
var grid = mini.get("searchList");
var da;
var a = 0;
//控制单元格是否可编辑 监听
grid.on("cellbeginedit", function (e) {
var task = e.record, column = e.column, field = e.field;
a = 1;
if (field == 'Status' && task.s2 != 1) {//task.s2数据库存储过程查询出的状态列 用于记录旧有的状态 因为status值(e.value)会被编辑改变
e.cancel = true;
return alert('已审核数据不可更改');//cancelEditRow ( row ) 触发监视过后emptytext="查看全部" shownullitem="true" nullitemtext="查看全部" 好像就无效了 造成了空行无效
}
});
function cancel() {//取消编辑
grid.reload();
}
function staffDDLChanged(e) {//员工下拉框变更
var id = e.value;
if (id) {
$('#RemarksDDL, #searchList, #btnS, #StatuDDL').show();
var url = "AJAX/a.aspx?type=SearchLogByUID&StaffID=" + id;
mini.get("RemarksDDL").setUrl(url);
mini.get("RemarksDDL").select(0);
grid.load({ uid: id }, function () {
uid = id; type = "s";
});/*, function () {
for (var i = 0; i < grid.data.length; i++) {
if (grid.data.Status != 1) {
alert(i);
//alert(getCellEditor(5, i + 1).value);
}
}
//alert(grid.data[0].rid);
}*/
} else $('#RemarksDDL, #searchList, #btnS, #StatuDDL').hide();
}
function onStatusRenderer(e) {//替换表格中的数字为值
for (var i = 0, l = Status.length; i < l; i++) {
var g = Status;
if (g.id == e.value) return g.text;
}
return "";
}
function RemarksDDLChanged(e) {//备注下拉框
var id = e.value;
if (id) {
grid.load({ id: id });
$('#StatuDDL').hide();
} else grid.load({ uid: uid }, function () {
$('#StatuDDL').show();
});
}
function StatuDDLChanged(e) {//状态下拉框
var id;
if (a == 0)
id = e.value;
else {
id = e.value - 1;
mini.get("StatuDDL").select(id -1);
}
if (id) {
grid.load({ uid: uid, status: id });
} else grid.load({ uid: uid }, function () {
$('#StatuDDL').show();
});
}
function saveData() {
var data = grid.getChanges();//object 格式的所有数据变更集合
var json = mini.encode(data);//被转成string的data
grid.loading("保存中,请稍后......");
var ids = [];
var status = [];
for (var i = 0; i < data.length; i++) {
var r = data;
ids.push(r.ID); status.push(r.Status);
}
var id = ids.join(',');//将数组用,拼接成字符串
var statu = status.join(',');
$.ajax({
url: "AJAX/a.aspx?type=SaveData",
data: { ids: id, status: statu },
type: "post",
success: function (text) {
grid.reload();
},
error: function (jqXHR, textStatus, errorThrown) {
alert(jqXHR.responseText);
}
});
}
</script>
</body>
</html>
|
|