asp.net mvc 之jqgird 列表数据 根据字典显示中文

 colModel: [
 
                {
                    name: "status", label: "状态", width: 70, align: "left",
                    formatter: function (cellvalue, options, rowObject) {
                       if (!!cellvalue) {
                            var v = cellvalue;
                            $.ajax({
                                url: "../../OpticManage/Cable/GetItemName",
                                data: { ItemId: "50415", keyValue: cellvalue },
                                async: false,
                                success: function (data) {
                                    v = data;
                                }
                            });
                            return v;
                        } else {
                            return "";
                        }
                    }
                },
 ],

 

Controller层  keyValue 是数据库存储的编号,ItemId是父编号
        [HttpGet]
        public ActionResult GetItemName(string keyValue, string ItemId)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("select ItemName from Base_DataItemDetail where ItemId='{0}' and ItemValue={1}", ItemId,keyValue);
            string itemname= dbbase.getValue(sb.ToString());
            return Content(itemname);
        }

 

posted @ 2018-08-21 14:46  执笔者  阅读(244)  评论(0编辑  收藏  举报