下拉选择仓库,带出仓库的描述在另外一列
因为服务里,设置OnGetValue不生效,所以选择写代码实现。
代码如下:
protected override void onl oad(System.EventArgs e) { base.OnLoad(e); Grid_OrdersDetails.RowUpdated += new JQGridEventHandler(Grid_OrdersDetailsRowUpdated);行更新事件 } public ResponseData Grid_OrdersDetailsRowUpdated(object sender, JQGridEventArgs args) { try { string rowid = args.State.RowID;//行id string ws = Convert.ToString((Grid_OrdersDetails.GridContext as BoundContext).GetCell(rowid, "SJ_Warehouse"));//得到变量 if (string.IsNullOrEmpty(ws)) { return args.Response; }
//去数据库查 string sql = String.Format(@"select sw.Description from SJ_Warehouse sw where sw.SJ_WarehouseName='{0}'", ws); QueryOptions _queryOptions = new QueryOptions() { QueryType = Camstar.WCF.ObjectStack.QueryType.User, ChangeCount = 0 }; RecordSet recordset; ResultStatus result; var qService = (Page as IForm).Service.GetService<QueryService>(); result = qService.ExecuteAdHoc(sql, _queryOptions, out recordset); DataTable dt = recordset.GetAsExplicitlyDataTable(); if (dt != null && dt.Rows != null && dt.Rows.Count > 0) {
//查询出来了,赋值 Grid_OrdersDetails.BoundContext.SetCell(rowid, "WarehouseName", dt.Rows[0]["Description"].ToString()); Grid_OrdersDetails.BoundContext.LoadData(); Page.RenderToClient = true; } } catch (Exception ex) { return args.Response; } return args.Response; }
标签:string,表格,recordset,带出,args,Grid,值后,dt,OrdersDetails From: https://www.cnblogs.com/CarryYou-lky/p/18052194