Example #1
0
        public static string GetWhereClause(JQGrid grid, string filters, string ignoreFilterField)
        {
            JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
            JsonMultipleSearch   jsonMultipleSearch   = javaScriptSerializer.Deserialize <JsonMultipleSearch>(filters);
            string text = "";

            foreach (MultipleSearchRule current in jsonMultipleSearch.rules)
            {
                if (string.IsNullOrEmpty(current.op))
                {
                    continue;
                }
                if (!string.IsNullOrWhiteSpace(ignoreFilterField) && current.field == ignoreFilterField)
                {
                    continue;
                }
                Util.SearchArguments args = new Util.SearchArguments
                {
                    SearchColumn    = current.field,
                    SearchString    = current.data,
                    SearchOperation = Util.GetSearchOperationFromString(current.op)
                };
                string str = (text.Length > 0) ? (" " + jsonMultipleSearch.groupOp + " ") : "";
                text = text + str + Util.ConstructLinqFilterExpression(grid, args);
            }
            return(text);
        }
Example #2
0
        private JsonResult GetJsonResponse()
        {
            Guard.IsNotNull(this.DataSource, "DataSource");
            IQueryable queryable = this.DataSource as IQueryable;

            Guard.IsNotNull(queryable, "DataSource", "should implement the IQueryable interface.");
            Guard.IsNotNullOrEmpty(this.DataField, "DataField", "should be set to the datafield (column) of the datasource to search in.");
            SearchOperation searchOperation;

            if (this.AutoCompleteMode == AutoCompleteMode.BeginsWith)
            {
                searchOperation = SearchOperation.BeginsWith;
            }
            else
            {
                searchOperation = SearchOperation.Contains;
            }
            string text = HttpContext.Current.Request.QueryString["term"];

            if (!string.IsNullOrEmpty(text))
            {
                queryable = queryable.Where(Util.ConstructLinqFilterExpression(this, new Util.SearchArguments
                {
                    SearchColumn    = this.DataField,
                    SearchOperation = searchOperation,
                    SearchString    = text
                }), new object[0]);
            }
            return(new JsonResult
            {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                Data = queryable.ToListOfString(this)
            });
        }
Example #3
0
        private JsonResult GetJsonResponse()
        {
            Guard.IsNotNull(this.DataSource, "DataSource");
            IQueryable dataSource = this.DataSource as IQueryable;

            Guard.IsNotNull(dataSource, "DataSource", "should implement the IQueryable interface.");
            Guard.IsNotNullOrEmpty(this.DataField, "DataField", "should be set to the datafield (column) of the datasource to search in.");
            SearchOperation isEqualTo = SearchOperation.IsEqualTo;

            if (this.AutoCompleteMode == Trirand.Web.Mvc.AutoCompleteMode.BeginsWith)
            {
                isEqualTo = SearchOperation.BeginsWith;
            }
            else
            {
                isEqualTo = SearchOperation.Contains;
            }
            string str = HttpContext.Current.Request.QueryString["term"];

            if (!string.IsNullOrEmpty(str))
            {
                Util.SearchArguments args = new Util.SearchArguments();
                args.SearchColumn    = this.DataField;
                args.SearchOperation = isEqualTo;
                args.SearchString    = str;
                dataSource           = dataSource.Where(Util.ConstructLinqFilterExpression(this, args), new object[0]);
            }
            JsonResult result2 = new JsonResult();

            result2.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            result2.Data = dataSource.ToListOfString(this);
            return(result2);
        }
Example #4
0
        public static string GetWhereClause(JQGrid grid, string searchField, string searchString, string searchOper)
        {
            string text  = " && ";
            string text2 = "";

            new Hashtable();
            Util.SearchArguments args = new Util.SearchArguments
            {
                SearchColumn    = searchField,
                SearchString    = searchString,
                SearchOperation = Util.GetSearchOperationFromString(searchOper)
            };
            string str  = (text2.Length > 0) ? text : "";
            string str2 = Util.ConstructLinqFilterExpression(grid, args);

            return(text2 + str + str2);
        }
Example #5
0
        public static string GetWhereClause(JQGrid grid, NameValueCollection queryString)
        {
            string text  = " && ";
            string text2 = "";

            new Hashtable();
            foreach (JQGridColumn current in grid.Columns)
            {
                string text3 = queryString[current.DataField];
                if (!string.IsNullOrEmpty(text3))
                {
                    Util.SearchArguments args = new Util.SearchArguments
                    {
                        SearchColumn    = current.DataField,
                        SearchString    = text3,
                        SearchOperation = current.SearchToolBarOperation
                    };
                    string str  = (text2.Length > 0) ? text : "";
                    string str2 = Util.ConstructLinqFilterExpression(grid, args);
                    text2 = text2 + str + str2;
                }
            }
            return(text2);
        }