示例#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));
 }