コード例 #1
0
        public static JsonQTable ConvertFromList <T>(List <T> list, string key, string[] cols, Func <string, bool> checkExtP, Func <string, T, string> exciteExtP) where T : class
        {
            JsonQTable data = new JsonQTable();

            data.page = 1;
            if (list != null)
            {
                data.total = list.Count;
                data.rows  = new List <JsonQRow>();
                foreach (T t in list)
                {
                    JsonQRow row = new JsonQRow();
                    row.id   = getValue <T>(t, key);
                    row.cell = new List <string>();
                    foreach (string col in cols)
                    {
                        if (checkExtP(col))
                        {
                            row.cell.Add(exciteExtP(col, t));
                        }
                        else
                        {
                            row.cell.Add(getValue <T>(t, col));
                        }
                    }
                    data.rows.Add(row);
                }
            }
            else
            {
                data.total = 0;
            }
            return(data);
        }
コード例 #2
0
        public static JsonQTable ConvertFromPagedList <T>(List <T> pageList, int pageIndex, int total, string key, string[] cols, Func <string, bool> checkExtP, Func <string, T, string> excuteExtP) where T : class
        {
            JsonQTable data = new JsonQTable();

            data.page  = pageIndex + 1;
            data.total = total;
            data.rows  = new List <JsonQRow>();
            foreach (T t in pageList)
            {
                JsonQRow row = new JsonQRow();
                row.id = getValue <T>(t, key);

                row.cell = new List <string>();
                foreach (string col in cols)
                {
                    if (checkExtP(col))
                    {
                        row.cell.Add(excuteExtP(col, t));
                    }
                    else
                    {
                        row.cell.Add(getValue <T>(t, col));
                    }
                }
                data.rows.Add(row);
            }
            return(data);
        }
コード例 #3
0
        public static JsonQTable ConvertFromPagedList <T>(List <T> pageList, int pageIndex, int total, string key, string[] cols) where T : class
        {
            JsonQTable data = new JsonQTable();

            data.page  = pageIndex + 1;
            data.total = total;
            data.rows  = new List <JsonQRow>();
            foreach (T t in pageList)
            {
                JsonQRow row = new JsonQRow();
                row.id   = getValue <T>(t, key);
                row.cell = new List <string>();
                foreach (string col in cols)
                {
                    row.cell.Add(getValue <T>(t, col));
                }
                data.rows.Add(row);
            }
            return(data);
        }