コード例 #1
0
ファイル: Searching.cs プロジェクト: gorbach/jqgrid.net
        private string ConstructFilterExpression(DataView view, JQGridSearchEventArgs args)
        {
            bool needsQuotes = view.ToTable().Columns[args.SearchColumn].DataType == typeof(string);
            string filterExpressionCompare = needsQuotes ? "[{0}] {1} '{2}'" : "[{0}] {1} {2}";
            string filterExpressionIn = "[{0}] {1} ({2})";
            string filterExpressionLike = "[{0}] LIKE '{1}'";
            string filterExpressionNotLike = "[{0}] NOT LIKE '{1}'";

            switch (args.SearchOperation)
            {
                case SearchOperation.IsEqualTo: return String.Format(filterExpressionCompare, args.SearchColumn, "=", args.SearchString);
                case SearchOperation.IsLessOrEqualTo: return String.Format(filterExpressionCompare, args.SearchColumn, "<=", args.SearchString);
                case SearchOperation.IsLessThan: return String.Format(filterExpressionCompare, args.SearchColumn, "<", args.SearchString);
                case SearchOperation.IsGreaterOrEqualTo: return String.Format(filterExpressionCompare, args.SearchColumn, ">=", args.SearchString);
                case SearchOperation.IsGreaterThan: return String.Format(filterExpressionCompare, args.SearchColumn, ">", args.SearchString);
                case SearchOperation.IsIn: return String.Format(filterExpressionIn, args.SearchColumn, "in", args.SearchString);
                case SearchOperation.IsNotIn: return String.Format(filterExpressionIn, args.SearchColumn, "not in", args.SearchString);
                case SearchOperation.BeginsWith: return String.Format(filterExpressionLike, args.SearchColumn, args.SearchString + "%");
                case SearchOperation.Contains: return String.Format(filterExpressionLike, args.SearchColumn, "%" + args.SearchString + "%");
                case SearchOperation.EndsWith: return String.Format(filterExpressionLike, args.SearchColumn, "%" + args.SearchString); 
                case SearchOperation.DoesNotBeginWith: return String.Format(filterExpressionNotLike, args.SearchColumn, args.SearchString + "%");
                case SearchOperation.DoesNotContain: return String.Format(filterExpressionNotLike, args.SearchColumn, "%" + args.SearchString + "%");
                case SearchOperation.DoesNotEndWith: return String.Format(filterExpressionNotLike, args.SearchColumn, "%" + args.SearchString);
            }

            throw new Exception("Invalid search operation.");
        }
コード例 #2
0
        private string ConstructLinqFilterExpression(DataView view, JQGridSearchEventArgs args)
        {
            DataFiltering dataFiltering = new DataFiltering();

            if (view != null)
            {
                return(dataFiltering.GetLinqFilterExpression(args.SearchOperation, args.SearchColumn, args.SearchString, view.ToTable().Columns[args.SearchColumn].DataType));
            }
            JQGridColumn jQGridColumn = this._grid.Columns.FromDataField(args.SearchColumn);

            Guard.IsNull(jQGridColumn, "SearchColumn", string.Format("Colunm {0} not found in grid - search cannot proceed.", args.SearchColumn));
            Guard.IsNull(jQGridColumn.DataType, "DataType", "DataType for the respective column must be set in order to get custom search string (where clause)");
            return(dataFiltering.GetLinqFilterExpression(args.SearchOperation, args.SearchColumn, args.SearchString, jQGridColumn.DataType));
        }
コード例 #3
0
ファイル: Searching.cs プロジェクト: gorbach/jqgrid.net
        public void PerformSearch(DataView view, string search)
        {
            if (!String.IsNullOrEmpty(search) && Convert.ToBoolean(search))
            {
                // search here                
                JQGridSearchEventArgs args = new JQGridSearchEventArgs()
                {
                    SearchColumn = _searchColunm,
                    SearchString = _searchString,
                    SearchOperation = GetSearchOperationFromString(_searchOperation)
                };
                _grid.OnSearching(args);                

                if (!args.Cancel)
                {
                    view.RowFilter = ConstructFilterExpression(view, args);                            
                }
                _grid.OnSearched(new EventArgs());
            }
        }
コード例 #4
0
        public string GetWhereClause(DataView view, bool isLinq)
        {
            string text = isLinq ? " && " : " AND ";

            new Hashtable();
            string text2 = string.Empty;

            foreach (JQGridColumn jQGridColumn in this._grid.Columns)
            {
                string text3 = "";
                if (this.IsToolBarSearch)
                {
                    text3 = this._grid.Page.Request[jQGridColumn.DataField];
                }
                else
                {
                    if (this._grid.Page.Request["searchField"] == jQGridColumn.DataField)
                    {
                        text3 = this._grid.Page.Request.QueryString["searchString"];
                    }
                }
                if (!string.IsNullOrEmpty(text3))
                {
                    JQGridSearchEventArgs jQGridSearchEventArgs = new JQGridSearchEventArgs
                    {
                        SearchColumn    = jQGridColumn.DataField,
                        SearchString    = text3,
                        SearchOperation = jQGridColumn.SearchToolBarOperation
                    };
                    this._grid.OnSearching(jQGridSearchEventArgs);
                    if (!jQGridSearchEventArgs.Cancel)
                    {
                        string str  = (text2.Length > 0) ? text : "";
                        string str2 = isLinq ? this.ConstructLinqFilterExpression(view, jQGridSearchEventArgs) : this.ConstructFilterExpression(view, jQGridSearchEventArgs);
                        text2 = text2 + str + str2;
                    }
                    this._grid.OnSearched(new EventArgs());
                }
            }
            return(text2);
        }
コード例 #5
0
 public void PerformSearch(DataView view)
 {
     JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
     JsonMultipleSearch jsonMultipleSearch = javaScriptSerializer.Deserialize<JsonMultipleSearch>(this._searchFilters);
     string text = "";
     foreach (MultipleSearchRule current in jsonMultipleSearch.rules)
     {
         JQGridSearchEventArgs jQGridSearchEventArgs = new JQGridSearchEventArgs
         {
             SearchColumn = current.field,
             SearchString = current.data,
             SearchOperation = base.GetSearchOperationFromString(current.op)
         };
         this._grid.OnSearching(jQGridSearchEventArgs);
         if (!jQGridSearchEventArgs.Cancel)
         {
             string str = (text.Length > 0) ? (" " + jsonMultipleSearch.groupOp + " ") : "";
             text = text + str + base.ConstructFilterExpression(view, jQGridSearchEventArgs);
         }
         view.RowFilter = text;
         this._grid.OnSearched(new EventArgs());
     }
 }
コード例 #6
0
        public void PerformSearch(DataView view)
        {
            JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
            JsonMultipleSearch   jsonMultipleSearch   = javaScriptSerializer.Deserialize <JsonMultipleSearch>(this._searchFilters);
            string text = "";

            foreach (MultipleSearchRule current in jsonMultipleSearch.rules)
            {
                JQGridSearchEventArgs jQGridSearchEventArgs = new JQGridSearchEventArgs
                {
                    SearchColumn    = current.field,
                    SearchString    = current.data,
                    SearchOperation = base.GetSearchOperationFromString(current.op)
                };
                this._grid.OnSearching(jQGridSearchEventArgs);
                if (!jQGridSearchEventArgs.Cancel)
                {
                    string str = (text.Length > 0) ? (" " + jsonMultipleSearch.groupOp + " ") : "";
                    text = text + str + base.ConstructFilterExpression(view, jQGridSearchEventArgs);
                }
                view.RowFilter = text;
                this._grid.OnSearched(new EventArgs());
            }
        }
コード例 #7
0
ファイル: Searching.cs プロジェクト: thanyaammyy/thaitaesc
 public void PerformSearch(DataView view, string search)
 {
     if (!string.IsNullOrEmpty(search) && Convert.ToBoolean(search))
     {
         JQGridSearchEventArgs jQGridSearchEventArgs = new JQGridSearchEventArgs
         {
             SearchColumn = this._searchColunm,
             SearchString = this._searchString,
             SearchOperation = base.GetSearchOperationFromString(this._searchOperation)
         };
         this._grid.OnSearching(jQGridSearchEventArgs);
         if (!jQGridSearchEventArgs.Cancel)
         {
             try
             {
                 view.RowFilter = base.ConstructFilterExpression(view, jQGridSearchEventArgs);
             }
             catch (Exception)
             {
             }
         }
         this._grid.OnSearched(new EventArgs());
     }
 }
コード例 #8
0
 public void PerformSearch(DataView view, string search)
 {
     if (!string.IsNullOrEmpty(search) && Convert.ToBoolean(search))
     {
         JQGridSearchEventArgs jQGridSearchEventArgs = new JQGridSearchEventArgs
         {
             SearchColumn    = this._searchColunm,
             SearchString    = this._searchString,
             SearchOperation = base.GetSearchOperationFromString(this._searchOperation)
         };
         this._grid.OnSearching(jQGridSearchEventArgs);
         if (!jQGridSearchEventArgs.Cancel)
         {
             try
             {
                 view.RowFilter = base.ConstructFilterExpression(view, jQGridSearchEventArgs);
             }
             catch (Exception)
             {
             }
         }
         this._grid.OnSearched(new EventArgs());
     }
 }
コード例 #9
0
 protected void JqgridMatch1_Searching(object sender, JQGridSearchEventArgs e)
 {
     if (e.SearchString == "[All]")
         e.Cancel = true;
 }
コード例 #10
0
ファイル: JQGrid.cs プロジェクト: gorbach/jqgrid.net
 internal protected virtual void OnSearching(JQGridSearchEventArgs e)
 {
     JQGridSearchEventHandler handler = (JQGridSearchEventHandler)base.Events[EventSearching];
     if (handler != null)
     {
         handler(this, e);
     }            
 }
コード例 #11
0
ファイル: JQGrid.cs プロジェクト: thanyaammyy/thaitaesc
 protected internal virtual void OnSearching(JQGridSearchEventArgs e)
 {
     JQGrid.JQGridSearchEventHandler jQGridSearchEventHandler = (JQGrid.JQGridSearchEventHandler)base.Events[JQGrid.EventSearching];
     if (jQGridSearchEventHandler != null)
     {
         jQGridSearchEventHandler(this, e);
     }
 }
コード例 #12
0
 public string GetWhereClause(DataView view, bool isLinq)
 {
     string text = isLinq ? " && " : " AND ";
     new Hashtable();
     string text2 = string.Empty;
     foreach (JQGridColumn jQGridColumn in this._grid.Columns)
     {
         string text3 = "";
         if (this.IsToolBarSearch)
         {
             text3 = this._grid.Page.Request[jQGridColumn.DataField];
         }
         else
         {
             if (this._grid.Page.Request["searchField"] == jQGridColumn.DataField)
             {
                 text3 = this._grid.Page.Request.QueryString["searchString"];
             }
         }
         if (!string.IsNullOrEmpty(text3))
         {
             JQGridSearchEventArgs jQGridSearchEventArgs = new JQGridSearchEventArgs
             {
                 SearchColumn = jQGridColumn.DataField,
                 SearchString = text3,
                 SearchOperation = jQGridColumn.SearchToolBarOperation
             };
             this._grid.OnSearching(jQGridSearchEventArgs);
             if (!jQGridSearchEventArgs.Cancel)
             {
                 string str = (text2.Length > 0) ? text : "";
                 string str2 = isLinq ? this.ConstructLinqFilterExpression(view, jQGridSearchEventArgs) : this.ConstructFilterExpression(view, jQGridSearchEventArgs);
                 text2 = text2 + str + str2;
             }
             this._grid.OnSearched(new EventArgs());
         }
     }
     return text2;
 }
コード例 #13
0
 private string ConstructLinqFilterExpression(DataView view, JQGridSearchEventArgs args)
 {
     DataFiltering dataFiltering = new DataFiltering();
     if (view != null)
     {
         return dataFiltering.GetLinqFilterExpression(args.SearchOperation, args.SearchColumn, args.SearchString, view.ToTable().Columns[args.SearchColumn].DataType);
     }
     JQGridColumn jQGridColumn = this._grid.Columns.FromDataField(args.SearchColumn);
     Guard.IsNull(jQGridColumn, "SearchColumn", string.Format("Colunm {0} not found in grid - search cannot proceed.", args.SearchColumn));
     Guard.IsNull(jQGridColumn.DataType, "DataType", "DataType for the respective column must be set in order to get custom search string (where clause)");
     return dataFiltering.GetLinqFilterExpression(args.SearchOperation, args.SearchColumn, args.SearchString, jQGridColumn.DataType);
 }