
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);
-
- }
欢迎加群讨论技术,1群:677373950(满了,可以加,但通过不了),2群:656732739
评价