ligerui列表显示

ligerui列表显示

1、引用
在这里插入图片描述

2、代码
前台:

function P_showList(productType, keyword) {
            var grid = $("#maingrid").ligerGrid({
                columns: [
                { display: "ID", name: "ID", width: 90, align: 'center' },
                { display: "产品编号", name: "FundCode", width: 90, align: 'center' },
                { display: "产品名称", name: "ProductcnName", width: 450, align: 'center' },
                { display: "TANO", name: "Tano", width: 50, align: 'center' },
                { display: "RAISETYPE", name: "RaiseType", width: 90, align: 'center' },
                { display: "公司类型", name: "CompanyType", width: 90, align: 'center' },
                ],
                url: '../../Ajax/FeeManage.ashx?action=GetProductList&productType=' + productType + "&keyword=" + keyword,
                parms: { where: f_getWhere() },
                pageSize: 15,
                pageSizeOptions: [5, 10, 15, 20, 30, 50],
                sortName: 'ID',
                sortOrder: 'desc',
                width: '85%', height: '90%',
                onLoading: function () {
                    cur_rows = new Array();
                },
                onDblClickRow: function (row) {
                    art.dialog.data('result', { "ID": row.ID, "FundCode": row.FundCode, "ProductcnName": row.ProductcnName, "Tano": row.Tano, "RaiseType": row.RaiseType, "CompanyType": row.CompanyType });
                    art.dialog.close();
                }
            });
            grid.toggleCol('ID', false);
        }

后台:

public void GetChannelList(HttpContext context)
    {
        try
        {
            int pageSize = Convert.ToInt32(context.Request["pageSize"]);
            int pageIndex = Convert.ToInt32(context.Request["page"]) - 1;
            string channelType = HttpUtility.UrlDecode(context.Request["channelType"]);
            string keyword = HttpUtility.UrlDecode(context.Request["keyword"]);
            string where = "1=1";
            if (!string.IsNullOrEmpty(channelType))
            {
                where += string.Format(" and seattp = {0} ", channelType);
            }
            if (!string.IsNullOrEmpty(keyword))
            {
                where += string.Format(" and (SeatNo like '%{0}%' or SeatNm like '%{0}%')", keyword);
            }
            IList<ChannelList> list = ChannelList.FindAll(where, "", null, pageIndex * pageSize, pageSize) ?? (new List<ChannelList>());
            if (list == null)
            {
                list = new List<ChannelList>();
            }
            int recordCount = ChannelList.FindCount(where, "", null, 0, 0);
            var result = JsonHelper.ListToJson2_noName(list);
            string json = @"{""Rows"":" + result + @",""Total"":""" + recordCount + @"""}";
            context.Response.ContentType = "application/Json";
            context.Response.Write(json);
            context.Response.End();
        }
        catch (Exception ex)
        {
            Unionstars.Trace.Log.WriteLine(ex.ToString());
        }

    }



 public static string ListToJson2_noName<T>(IList<T> list)
    {
        if (list.Count == 0) return "[]";
        object obj = list[0];

        return ListToJson2_noName_detail<T>(list);
    }

public static string ListToJson2_noName_detail<T>(IList<T> list)
    {
        StringBuilder Json = new StringBuilder();
        //if (string.IsNullOrEmpty(jsonName))
        //    jsonName = list[0].GetType().Name;
        Json.Append("[");
        if (list.Count > 0)
        {
            for (int i = 0; i < list.Count; i++)
            {
                T obj = Activator.CreateInstance<T>();
                PropertyInfo[] pi = obj.GetType().GetProperties();

                pi = Filter(pi, new List<string> { "Int32", "String", "DateTime", "Boolean", "Double" });
                Json.Append("{");
                for (int j = 0; j < pi.Length; j++)
                {
                    Type type = pi[j].GetValue(list[i], null).GetType();
                    Json.Append("\"" + pi[j].Name.ToString() + "\":" + StringFormat(pi[j].GetValue(list[i], null).ToString(), type));

                    if (j < pi.Length - 1)
                    {
                        Json.Append(",");
                    }
                }
                Json.Append("}");
                if (i < list.Count - 1)
                {
                    Json.Append(",");
                }
            }
        }
        Json.Append("]");
        return Json.ToString();
    }




 public static PropertyInfo[] Filter(PropertyInfo[] oldpro, List<string> pnames)
    {
        List<PropertyInfo> lspro = new List<PropertyInfo>(oldpro);
        for (int i = 0; i < lspro.Count; i++)
        {
            if (!pnames.Contains(lspro[i].PropertyType.Name))
            {
                lspro.RemoveAt(i);
                i--;
            }
        }
        return lspro.ToArray();
    }




  private static string StringFormat(string str, Type type)
    {
        if (type == typeof(string))
        {
            str = String2Json(str);
            str = "\"" + str + "\"";
        }
        else if (type == typeof(DateTime))
        {
            str = "\"" + str + "\"";
        }
        else if (type == typeof(bool))
        {
            str = str.ToLower();
        }
        return str;
    }



   private static string String2Json(String s)
    {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < s.Length; i++)
        {
            char c = s.ToCharArray()[i];
            switch (c)
            {
                case '\"':
                    sb.Append("\\\""); break;
                case '\\':
                    sb.Append("\\\\"); break;
                case '/':
                    sb.Append("\\/"); break;
                case '\b':
                    sb.Append("\\b"); break;
                case '\f':
                    sb.Append("\\f"); break;
                case '\n':
                    sb.Append("\\n"); break;
                case '\r':
                    sb.Append("\\r"); break;
                case '\t':
                    sb.Append("\\t"); break;
                default:
                    sb.Append(c); break;
            }
        }
        return sb.ToString();
    }

3、

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值