Exemplo n.º 1
0
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            try
            {
                var request  = controllerContext.HttpContext.Request;
                var grdParms = new GridSettings
                {
                    IsSearch   = bool.Parse(request["_search"] ?? "false"),
                    PageIndex  = int.Parse(request["page"] ?? "1"),
                    PageSize   = int.Parse(request["rows"] ?? "10"),
                    SortColumn = request["sidx"] ?? "",
                    SortOrder  = request["sord"] ?? "asc"
                };

                if (request["_search"] == "true" && request["searchField"] != null)
                {
                    var advFilters = string.Format("{{\"groupOp\":\"AND\",\"rules\":[{{\"field\":\"{0}\",\"op\":\"{1}\",\"data\":\"{2}\"}}]}}", request["searchField"], request["searchOper"], request["searchString"]);
                    grdParms.Where = JqGridFilter.Create(advFilters);
                }
                else
                {
                    grdParms.Where = JqGridFilter.Create(request["filters"] ?? "");
                }

                return(grdParms);
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 2
0
        //METHODS
        public void AddRule(JqGridRule rule)
        {
            if (Where == null)
            {
                Where = new JqGridFilter();
            }
            List <JqGridRule> rules = Where.Rules == null ? new List <JqGridRule>() : Where.Rules.ToList();

            rules.Add(rule);
            Where.Rules = rules.ToArray();
        }
Exemplo n.º 3
0
        public void RemoveRuleByName(string name)
        {
            if (Where == null)
            {
                Where = new JqGridFilter();
            }
            List <JqGridRule> rules        = Where.Rules == null ? new List <JqGridRule>() : Where.Rules.ToList();
            JqGridRule        ruleToRemove = rules.FirstOrDefault(jqGridRule => jqGridRule.Field.Equals(name));

            if (ruleToRemove != null)
            {
                rules.Remove(ruleToRemove);
            }

            Where.Rules = rules.ToArray();
        }