Пример #1
0
        public JqGridReturnBuilder(List <T> lista, GridSettings gridSettings)
        {
            _qtdeRegistro = lista.Count();

            Retorna = new JqGridReturn
            {
                records = _qtdeRegistro,
                page    = gridSettings.PageIndex,
                total   = (int)Math.Ceiling(_qtdeRegistro / (decimal)gridSettings.PageSize),
                rows    = lista
            };
        }
Пример #2
0
        public JqGridReturnBuilder(IQueryable <T> lista, GridSettings gridSettings)
        {
            _GridSettings = gridSettings;
            _lista        = lista;


            if (gridSettings.Where != null)
            {
                foreach (var item in gridSettings.Where.rules.Where(c => c.data != ""))
                {
                    switch (item.op)
                    {
                    case "eq":
                        _lista = _lista.Where(string.Concat(item.field, " = " + ProcessaValor(item.data)));
                        break;

                    case "cn":
                        _lista = _lista.Where(string.Concat(item.field, ".contains(\"", item.data, "\")"));
                        break;

                    case "bool":
                        _lista = _lista.Where(string.Concat(item.field, " = ", item.data));
                        break;

                    default:
                        _lista = _lista.Where(string.Concat(item.field, " ", item.op, " ", ProcessaValor(item.data)));
                        break;
                    }
                }
            }

            _qtdeRegistro = _lista.Count();
            Retorna       = new JqGridReturn
            {
                records = _qtdeRegistro,
                page    = gridSettings.PageIndex,
                total   = (int)Math.Ceiling(_qtdeRegistro / (decimal)gridSettings.PageSize),
            };
        }
Пример #3
0
 public static string ToJqGrid <T>(this List <T> lista, GridSettings gridSettings)
 {
     return(new JqGridReturnBuilder <T>(lista, gridSettings).Retorna.ToJson());
 }
Пример #4
0
 public static JqGridReturnBuilder <T> ToJqGrid <T>(this IQueryable <T> valor, GridSettings gridSettings)
 {
     return(new JqGridReturnBuilder <T>(valor, gridSettings));
 }