EasyUI datagrid表中编辑

5 篇文章 0 订阅

 <script type="text/javascript">
        //OpenWindow("/RUpdate_Meet.aspx?id=" + id + "&op=" + op, "修改会议", "", 800, 510);
        function OpenWindow(Content, title, type, width, height) {
            var topsize = document.documentElement.scrollTop; var leftsize = 0;
            if (type.length == 0) { type = "iframe"; }
            if (width != 0) { leftsize = (window.screen.availWidth - width) / 4; } //弹出框 可左右移动 调节
            if (height != 0) {      //上下
                if (height > 600) { topsize += 10; } else if (height > 500) { topsize += 20; } else { topsize += (window.screen.availHeight - height - 130) / 4; }
            }
            ///显示子页面
            if (type == 'iframe') {
                $("#menu_window").html("<iframe id='ifrme' name='ifrme' frameborder='0' scrolling='auto' width='" + width + "' height='" + height + "'></iframe>");
                $("#ifrme").attr("src", Content);
            }
            ///用于 弹出子页面
            $("#menu_window").window({
                title: title, iconCls: 'icon-info', width: width + 15, height: height + 40, top: topsize, left: leftsize, resizable: false, modal: true, shadow: true,
                minimizable: false, maximizable: false, closable: true, closed: false, collapsible: false
            });
        }
        function CloseWindow() { $('#menu_window').window('close'); LoadGrid(); }
        $(function () {
            LoadGrid();
            // $('#link_Add').click(function () {//添加按钮绑定窗口功能
            //   parent.OpenWindow("VisaPriceAdd.aspx", "新增报价", "", 440, 270);
            //  });
        })
        function LoadGrid() {
            $('#datas').datagrid({
                url: '/AjaxSource/Visa_Price_List.ashx',
                fitColumns: true, pageList: [15],
                pagination: true, striped: false,
                height: ($(window).height() * 0.90),
                singleSelect: true,
                iconCls: 'icon-edit',
                queryParams: { "opt": "search", "k": encodeURI($("#ddlKey").val()),
                    "sousuo": encodeURI($("#txtsousuo").val()),
                    "Country": encodeURI($("#listCountry option:selected ").text()),
                    "ComUU": encodeURI($("#ComUU").val())
                },
                columns: [[
           { field: 'ck', checkbox: true },
           { field: 'ID', title: '编号', width: 10, align: 'center' },
                    { field: 'CP_ID', title: '产品', width: 10, align: 'center' },
                    { field: 'LSGName', title: '领事馆', width: 30, align: 'center' },
                    { field: 'ComName', title: '公司', width: 40, align: 'center' },
              { field: 'PassName', title: '签证', width: 30, align: 'center',
                  formatter: function (v, r, i) {
                      if (v != "" && v != null) {
                          return v;
                      }
                      return "<font color='red'>无签证产品</font><img src='/Icon/user_delete.gif'/>";
                  }
              },

              { field: 'Sheng', title: '地域', width: 30, align: 'center',
                  formatter: function (v, r, i) {
                      if (r.Shi != "") {
                          return v + r.Shi;
                      }
                      return v;
                  }
              },
                    { field: 'SLSheng', title: '受理', width: 30, align: 'center' },
                    { field: 'ToCountry', title: '目的', width: 20, align: 'center' },
                    { field: 'P_Guest', title: '客人价', width: 12, align: 'center', editor: 'numberbox' },
                    { field: 'P_GY', title: '同行价', width: 12, align: 'center', editor: 'numberbox' },
                    { field: 'P_GY_CB', title: '成本', width: 12, align: 'center', editor: 'numberbox' }, //text P_Guest P_GY P_GY_CB

                      {field: 'order', title: '订单', width: 10, align: 'center',
                      formatter: function (v, r, i) {
                          return "<img src='/icon/ck.gif'  style='cursor:pointer' οnclick='Check(" + r.ID + ")'/>";
                      }
                  },
          { field: 'action', title: '操作', width: 15, align: 'center',
              formatter: function (value, row, index) {
                  if (row.editing) {
                      var s = "<img src='/icon/add.png'  style='cursor:pointer' οnclick='saverow(" + index + ")'/>";
                      var c = "<img src='/icon/del.gif' style='cursor:pointer' οnclick='Del(" + row.ID + ")'>";
                      return s + " " + c;
                  } else {
                      var e = "<img src='/icon/option.gif'  style='cursor:pointer' οnclick='editrow(" + index + ")'/>";
                      var d = "<img src='/icon/del.gif' style='cursor:pointer' οnclick='Del(" + row.ID + ")'>";
                      return e + " " + d;
                  }
              }
          }
          ]],
                onSortColumn: function (sortname, order) {
                    Sorts('datas', sortname, order);
                },
                onLoadSuccess: function (data) {
                },
                onLoadErrir: function (data) {
                },
                onDblClickRow: function (index, row) {
                    row.editing = true;
                    $('#datas').datagrid('beginEdit', index);
                },
                onBeforeEdit: function (index, row) {
                    row.editing = true;
                    $('#datas').datagrid('refreshRow', index);
                },
                onAfterEdit: function (index, row) {
                    row.editing = false;
                    $('#datas').datagrid('refreshRow', index); //P_Guest P_GY P_GY_CB
                    Soft_Update(row.ID, row.P_Guest, row.P_GY, row.P_GY_CB);
                },
                onCancelEdit: function (index, row) {
                    row.editing = false;
                    $('#datas').datagrid('refreshRow', index);
                }
            });
        }
        ///单行编辑 
        function Soft_Update(ID, P_Guest, P_GY, P_GY_CB) {
            if (confirm("确定修改吗?")) {
                $.post('/AjaxSource/Visa_Price_List.ashx', { "opt": "UpPrice", "ID": ID, "P_Guest": P_Guest, "P_GY": P_GY, "P_GY_CB": P_GY_CB },
               function (r) {
                   if (r == "1") {
                       Shows("温馨提示", "成功!", "slide", 5000);
                       LoadGrid();
                   }
                   else {
                       Shows("温馨提示", "失败", "slide", 5000);
                   }
               })
            }
        }

        function Dels() {
            var json = $('#datas').datagrid('getSelections'); var ids = ""
            if (json.length > 0) {
                $.each(json, function (i, n) {
                    ids += n.ID + ",";
                });
            } else { return; };
            if (ids.length > 0) {
                Del(ids.substring(0, ids.length - 1));
            }
        }
        function Del(delid) {
            if (confirm("确定修改么?")) {
                $.post('/AjaxSource/Visa_Price_List.ashx', { "opt": "del", "id": delid }, function (r) {
                    if (r == "1") {
                        Shows("温馨提示", "成功!", "slide", 5000);
                        LoadGrid();
                    } else {
                        Shows("温馨提示", "失败", "slide", 5000);
                    }
                })
            }
        }
        //排序
        function Sorts(datagridID, sortName, sortOrder) {
            var params = $('#' + datagridID).datagrid('options').queryParams;
            params.sortName = sortName;
            params.sortOrder = sortOrder;
            $("#" + datagridID).datagrid('reload');
        }

        function saverow(index) {
            $('#datas').datagrid('endEdit', index);
        }
        function getRowIndex(target) {
            var tr = $(target).closest('tr.datagrid-row');
            return parseInt(tr.attr('datagrid-row-index'));
        }
        function editrow(target) {
            $('#datas').datagrid('beginEdit', target);
        }
        //更新
        function Update(id) {
            OpenWindow("VisaPriceAdd.aspx?id=" + id, "修改", "", 420, 260);
        }
        //订单
        function Check(id) {
            OpenWindow("Visa_Order_List.aspx?QZPID=" + id, "订单", "", 900, 450);
        }
    </script>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值