MongoDB学习笔记(三)在MVC模式下通过Jqgrid表格操作MongoDB数据(3)

来源:未知 责任编辑:责任编辑 发表时间:2013-11-15 19:51 点击:
                        return;
                    }
                    Delete(id);
                }
            }).navButtonAdd('#div1', {
                caption: "新增",
                buttonicon: "ui-icon-add",
                onClickButton: function () {
                    $("#table1").addRowData("newId", -1);
                    $("#table1").editRow("newId");
                    $("#table1").setCell("newId", "Edit", "<input id='Button1' type='button' value='提交' onclick='Add()' /><input id='Button2' type='button' value='取消' onclick='Cancel(\"newId\")' />");
                }
            });
});
 
//取消编辑状态
function Cancel(id) {
    if (id == "newId") $("#table1").delRowData("newId");
    else $("#table1").restoreRow(id);
}
 
//向后台ajax请求新增数据
function Add() {
    var UserId = $("#table1").find("#newId" + "_UserId").val();
    var UserName = $("#table1").find("#newId" + "_UserName").val();
    var Age = $("#table1").find("#newId" + "_Age").val();
    var Tel = $("#table1").find("#newId" + "_Tel").val();
    var Email = $("#table1").find("#newId" + "_Email").val();
 
    $.ajax({
        type: "POST",
        url: "/Home/Add",
        data: "UserId=" + UserId + "&UserName=" + UserName + "&Age=" + Age + "&Tel=" + Tel + "&Email=" + Email,
        success: function (msg) {
            alert("新增数据: " + msg);
            $("#table1").trigger("reloadGrid");
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
用户名: 验证码:点击我更换图片
最新评论 更多>>

推荐热点

  • Request.ServerVariables 参数大全
  • 执行全文索引时出现权限不足的解决方法
  • 导入excel文件处理流程节点的解决方案
  • 查看sql修改痕迹(SQL Change Tracking on Table)
  • App数据层设计及云存储使用指南
  • PostgreSQL启动过程中的那些事三:加载GUC参数
  • MongoDB安装为Windows服务方法与注意事项
  • Percolator与分布式事务思考(二)
  • 写给MongoDB开发者的50条建议Tip1
网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
Copyright © 2008-2015 计算机技术学习交流网. 版权所有

豫ICP备11007008号-1