- 注册时间
- 2017-2-21
- 最后登录
- 1970-1-1
- 阅读权限
- 10
- 积分
- 103
- 精华
- 0
- 帖子
- 24
|
function edit() {
var row = grid.getSelected();
if (row) {
mini.open({
url: "/sysEnum/editenum",
title: "编辑枚举类别", width: 600, height: 400,
onload: function () {
var iframe = this.getIFrameEl();
var data = { action: "edit", pk: row.pk, enumtype: row.enumtype};
&&这个写法对方我想传递pk和enumtype字段的值
iframe.contentWindow.SetData(data);
},
ondestroy: function (action) {
//var iframe = this.getIFrameEl();
grid.reload();
}
});
} else {
alert("请选中一条记录");
}
}
////////////////////
//标准方法接口定义
function SetData(data) {
if (data.action == "edit") {
//跨页面传递的数据对象,克隆后才可以安全使用
data = mini.clone(data);
$("#enumtype").value = data.enumtype;
$("#pk").value = data.pk;
}
}
但是没有把数据传到页面中
数据保存的C# 代码 前台没有传递 _state 元素值过来
public ActionResult SaveEnum()
{
String json = Request["data"];
string lcSql = "";
string pk = "";
String state;
string enumtype;
int nInt = 0;
try
{
ArrayList rows = (ArrayList)JSON.Decode(json);
foreach (Hashtable row in rows)
{
//根据记录状态,进行不同的增加、删除、修改操作
state = row["_state"] != null ? row["_state"].ToString() : "";
pk = row["pk"] != null ? row["pk"].ToString() : "";
//pk = (row["pk"] == null || row["pk"].ToString() == "") ? Guid.NewGuid().ToString().Substring(0,20) : row["pk"].ToString();
enumtype = (row["enumtype"] == null || row["enumtype"].ToString() == "") ? "" : row["enumtype"].ToString();
if (state == "added" || pk == "" ) //新增:id为空,或_state为added
{
pk = Guid.NewGuid().ToString().Substring(0, 20);
lcSql = "insert into cpsenum (pk,enumtype)" + " values('" + pk + "', :enumtype)";
}
else if (state == "modified" || state=="") //更新:_state为空或modified
{
lcSql = "update cpsenum set enumtype=:enumtype where pk='" + pk + "'";
}
OracleParameter[] sqlpm = new OracleParameter[1];
sqlpm[0] = new OracleParameter("enumtype", OracleType.VarChar, 255);
sqlpm[0].Value = enumtype;
nInt = OraDataBase.ExecuteSql(lcSql, ConfigurationManager.AppSettings["OraNcConnectionString"], sqlpm);
}
return Json(new { code = "0", msg = "成功删除数据" + nInt.ToString() + "条" }, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
cpsWeixin.Common.LogManager.WriteLog("errDataBase", "错误" + ex.Message + "sql=" + lcSql);
return Json(new { code = "-2", msg = "系统错误" }, JsonRequestBehavior.AllowGet);
}
}
|
|