Exemple #1
0
        /// <summary>
        /// Get current filter expression from grid view model
        /// </summary>
        /// <param name="gridViewModel"></param>
        /// <returns></returns>
        public static string GetCurrentFilterExpression(GridViewModel gridViewModel)
        {
            StringBuilder retVal = new StringBuilder();

            if (gridViewModel.GridFilters != null)
            {
                foreach (GridViewFilter gridFilter in gridViewModel.GridFilters)
                {
                    GridViewColumn gridColumn = gridViewModel.GridViewColumns.FirstOrDefault(x => x.ColumnName == gridFilter.ColumnName);

                    retVal.Append(" ");

                    if (gridColumn != null && !string.IsNullOrEmpty(gridColumn.SortExpression))
                    {
                        retVal.Append(gridColumn.SortExpression);
                    }
                    else
                    {
                        retVal.Append(gridFilter.ColumnName);
                    }

                    retVal.Append(
                        gridViewModel.GetFilterExpression((GridFilterOperatorType)gridFilter.QueryOperator));
                    retVal.Replace(GridViewConstants.FilterPlaceholder,
                                       gridFilter.FilterValue.Replace("'", "''"));
                    retVal.Append(GridViewUtility.AndString);
                }
            }

            if (retVal.Length > 0)
            {
                retVal.Length -= GridViewUtility.AndString.Length;
            }

            return retVal.ToString();
        }
Exemple #2
0
        /// <summary>
        /// Get current filter expression from grid view model
        /// </summary>
        /// <param name="gridViewModel"></param>
        /// <returns></returns>
        public static string GetCurrentFilterExpression(GridViewModel gridViewModel)
        {
            StringBuilder retVal = new StringBuilder();

            if (gridViewModel.GridFilters != null)
            {
                foreach (GridViewFilter gridFilter in gridViewModel.GridFilters)
                {
                    GridViewColumn gridColumn = gridViewModel.GridViewColumns.FirstOrDefault(x => x.ColumnName == gridFilter.ColumnName);

                    retVal.Append(" ");

                    if (gridColumn != null && !string.IsNullOrEmpty(gridColumn.SortExpression))
                    {
                        retVal.Append(gridColumn.SortExpression);
                    }
                    else
                    {
                        retVal.Append(gridFilter.ColumnName);
                    }

                    retVal.Append(
                        gridViewModel.GetFilterExpression((GridFilterOperatorType)gridFilter.QueryOperator));
                    retVal.Replace(GridViewConstants.FilterPlaceholder,
                                   gridFilter.FilterValue.Replace("'", "''"));
                    retVal.Append(GridViewUtility.AndString);
                }
            }

            if (retVal.Length > 0)
            {
                retVal.Length -= GridViewUtility.AndString.Length;
            }

            return(retVal.ToString());
        }