Esempio n. 1
0
        public static JsonFlexiGridData ConvertFromPagedList <T>(PagedList <T> pagelist, string key, string[] cols) where T : class
        {
            JsonFlexiGridData data = new JsonFlexiGridData();

            data.page = pagelist.PageIndex + 1;
            if (pagelist.PageIndex == 0)
            {
                data.total = pagelist.Total;
            }
            else
            {
                data.total = -1;
            }
            data.rows = new List <FlexiGridRow>();
            foreach (T t in pagelist.DataList)
            {
                FlexiGridRow row = new FlexiGridRow();
                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);
        }
Esempio n. 2
0
        public static JsonFlexiGridData ConvertFromList <T>(List <T> list, string key, string[] cols) where T : class
        {
            JsonFlexiGridData data = new JsonFlexiGridData();

            data.page = 1;
            if (list != null)
            {
                data.total = list.Count;
                data.rows  = new List <FlexiGridRow>();
                foreach (T t in list)
                {
                    FlexiGridRow row = new FlexiGridRow();
                    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);
                }
            }
            else
            {
                data.total = 0;
            }
            return(data);
        }