EasyUI弹窗批量修改combogrid下拉框的值

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/ohdajing/article/details/81095056

 JS方法

      //点击弹出批量修改框  
        UpdateLot: function () {
            var row = $("#dg").datagrid("getChecked");
            if (row.length < 1) {
                toastr.warning("请先选择要修改的记录");
                return;
            }

            $('#UpdateLot').modal('show');
        },

        //显示弹框中下拉框的数据
        showList: function () {

            $('#txtTerminalID').combogrid({
                //panelWidth: 500,
                idField: 'TerminalID', //ID字段  
                textField: 'TerminalID', //显示的字段  
                fitColumns: true,
                editable: false,

                columns: [[
                    { field: 'TerminalID', title: '终端ID', sortable: true, width: 100 },
                    { field: 'Name', title: '名称', sortable: true, width: 150 }
                ]],
                onSelect: function (index, row) {
                    reloadadr(row.TerminalID);
                }, onLoadSuccess: function () {
                    //默认选中第一行      
                    $('#txtTerminalID').combogrid('grid').datagrid('selectRow', 0);
                }
            });
            $('#txtADRCode').combogrid({
                idField: 'ADRCode',
                textField: 'ADRCode',
                editable: false,
                columns: [[
                   { field: 'TerminalID', title: '终端ID', sortable: true, width: 100 },
                    { field: 'ADRCode', title: '地址码', sortable: true, width: 150 }
                ]],
                onLoadSuccess: function () {
                    //默认选中第一行      
                    $('#txtADRCode').combogrid('grid').datagrid('selectRow', 0);
                }
            });

            $.post("/Pile/GetDataById?id=" + 0, function (data) {
                var editdata = $.parseJSON(data);
                reloadte(1);
                $('#txtSite_ID').combogrid('setValue', 1);
                $('#txtTerminalID').combogrid('setValue', editdata[0].TerminalID);
                $('#txtADRCode').combogrid('setValue', editdata[0].ADRCode);

            });
        },
        UpteLot: function () {
            var parmId = "";
            var TerminalID = $("#txtTerminalID").combogrid("getValue").toString();
            var ADRCode = $("#txtADRCode").combogrid("getValue").toString();
            var rows = $("#dg").datagrid("getChecked");
            //循环遍历要修改的ID
            $.each(rows, function (i, row) {
                parmId += row.ID + ",";
            });     
            $.ajax({
                url: "/Pile/UpdatePile",
                data: {
                    IDs: parmId,
                    TerminalID: TerminalID,
                    ADRCode: ADRCode,
                },
        
                type: "POST",
                dataType: "json",
                success: function (data) {
                    if (data.errortype==true) {
                        // 成功后的操作                       
                        window.location.href = "/Pile/Index";
                    }
                    else {
                        toastr.error(data.result);
                    }
                }

            });
        }

 Controller修改方法


        public ActionResult UpdatePile()
        {
            string parmIds = Request["IDs"];
            string TerminalID = Request["TerminalID"];
            string ADRCode = Request["ADRCode"];

            string strsql = string.Format("update AppCHCPile set TerminalID='{0}',ADRCode='{1}' where ID in ({2})", TerminalID, ADRCode, parmIds.TrimEnd(','));
            //将获得的数据作JSON对象抛回
            var data = new
            {
                errortype = YLSBLL.BLLComm.SqlExec(strsql),

            };
            return Json(data, JsonRequestBehavior.AllowGet);

        }

猜你喜欢

转载自blog.csdn.net/ohdajing/article/details/81095056