Beispiel #1
0
        /// <summary>
        ///     Provides query, using by the grid
        /// </summary>
        public void AddQueryParameter(string parameterName, StringValues parameterValue)
        {
            if (string.IsNullOrEmpty(parameterName))
            {
                throw new ArgumentException("parameterName");
            }
            if (parameterName.Equals(QueryStringFilterSettings.DefaultTypeQueryParameter))
            {
                throw new ArgumentException("parameterName cannot be " + QueryStringFilterSettings.DefaultTypeQueryParameter);
            }

            if (_query.ContainsKey(parameterName))
            {
                _query[parameterName] = parameterValue;
            }
            else
            {
                _query.Add(parameterName, parameterValue);
            }

            _settings = new QueryStringGridSettingsProvider(_query);
            _columnsCollection.SortSettings = _settings.SortSettings;
            _columnsCollection.UpdateColumnsSorting();
            ((GridPager)_pager).Query = _query;
        }
        protected override void OnParametersSet()
        {
            _filterComponents = new QueryDictionary <Type>();
            _filterComponents.Add("System.String", typeof(TextFilterComponent <T>));
            _filterComponents.Add("System.Int32", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.Double", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.Decimal", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.Byte", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.Single", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.Float", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.Int64", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.Int16", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.UInt64", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.UInt32", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.UInt16", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.DateTime", typeof(DateTimeFilterComponent <T>));
            _filterComponents.Add("System.Date", typeof(DateTimeFilterComponent <T>));
            _filterComponents.Add("System.DateTimeOffset", typeof(DateTimeFilterComponent <T>));
            _filterComponents.Add("System.Boolean", typeof(BooleanFilterComponent <T>));

            if (CustomFilters != null)
            {
                foreach (var widget in CustomFilters)
                {
                    if (_filterComponents.ContainsKey(widget.Key))
                    {
                        _filterComponents[widget.Key] = widget.Value;
                    }
                    else
                    {
                        _filterComponents.Add(widget);
                    }
                }
            }
        }
        protected override void OnParametersSet()
        {
            _filterComponents = new QueryDictionary <Type>();
            _filterComponents.Add("System.String", typeof(TextFilterComponent <T>));
            _filterComponents.Add("System.Guid", typeof(TextFilterComponent <T>));
            _filterComponents.Add("System.Int32", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.Double", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.Decimal", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.Byte", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.Single", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.Float", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.Int64", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.Int16", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.UInt64", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.UInt32", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.UInt16", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.DateTime", typeof(DateTimeFilterComponent <T>));
            _filterComponents.Add("System.Date", typeof(DateTimeFilterComponent <T>));
            _filterComponents.Add("System.DateTimeOffset", typeof(DateTimeFilterComponent <T>));
            _filterComponents.Add("DateTimeLocal", typeof(DateTimeLocalFilterComponent <T>));
            _filterComponents.Add("Week", typeof(WeekFilterComponent <T>));
            _filterComponents.Add("Month", typeof(MonthFilterComponent <T>));
            _filterComponents.Add("System.Boolean", typeof(BooleanFilterComponent <T>));

            if (CustomFilters == null)
            {
                CustomFilters = new QueryDictionary <Type>();
            }
            if (CustomFilters.Any(r => r.Key.Equals(SelectItem.ListFilter)))
            {
                CustomFilters.Remove(SelectItem.ListFilter);
            }
            CustomFilters.Add(SelectItem.ListFilter, typeof(ListFilterComponent <T>));
            foreach (var widget in CustomFilters)
            {
                if (_filterComponents.ContainsKey(widget.Key))
                {
                    _filterComponents[widget.Key] = widget.Value;
                }
                else
                {
                    _filterComponents.Add(widget);
                }
            }

            FirstColumn = (IGridColumn <T>)Grid.Columns.FirstOrDefault();

            if (OnRowClickedActions != null && OnRowClickedActions.Count() > 0)
            {
                OnRowClicked = OnRowClickedActions.First();
            }

            _hasSubGrid           = Grid.SubGridKeys != null && Grid.SubGridKeys.Length > 0;
            _hasTotals            = Grid.IsSumEnabled || Grid.IsAverageEnabled || Grid.IsMaxEnabled || Grid.IsMinEnabled;
            _requiredTotalsColumn = _hasTotals &&
                                    FirstColumn != null &&
                                    (FirstColumn.IsSumEnabled || FirstColumn.IsAverageEnabled ||
                                     FirstColumn.IsMaxEnabled || FirstColumn.IsMinEnabled);

            HeaderComponents = new QueryDictionary <GridHeaderComponent <T> >();

            InitCheckboxAndSubGridVars();
            InitCheckedKeys();

            var queryBuilder          = new CustomQueryStringBuilder(Grid.Settings.SearchSettings.Query);
            var exceptQueryParameters = new List <string> {
                GridPager.DefaultPageSizeQueryParameter
            };

            _changePageSizeUrl = queryBuilder.GetQueryStringExcept(exceptQueryParameters);
            _pageSize          = Grid.Pager.ChangePageSize && Grid.Pager.QueryPageSize > 0 ? Grid.Pager.QueryPageSize : Grid.Pager.PageSize;

            _shouldRender = true;
        }
        protected override void OnParametersSet()
        {
            _filterComponents = new QueryDictionary <Type>();
            _filterComponents.Add("System.String", typeof(TextFilterComponent <T>));
            _filterComponents.Add("System.Int32", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.Double", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.Decimal", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.Byte", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.Single", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.Float", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.Int64", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.Int16", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.UInt64", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.UInt32", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.UInt16", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.DateTime", typeof(DateTimeFilterComponent <T>));
            _filterComponents.Add("System.Date", typeof(DateTimeFilterComponent <T>));
            _filterComponents.Add("System.DateTimeOffset", typeof(DateTimeFilterComponent <T>));
            _filterComponents.Add("System.Boolean", typeof(BooleanFilterComponent <T>));

            if (CustomFilters != null)
            {
                foreach (var widget in CustomFilters)
                {
                    if (_filterComponents.ContainsKey(widget.Key))
                    {
                        _filterComponents[widget.Key] = widget.Value;
                    }
                    else
                    {
                        _filterComponents.Add(widget);
                    }
                }
            }

            FirstColumn = (ICGridColumn)Grid.Columns.FirstOrDefault();

            _hasSubGrid           = Grid.Keys != null && Grid.Keys.Length > 0;
            _hasTotals            = Grid.IsSumEnabled || Grid.IsAverageEnabled || Grid.IsMaxEnabled || Grid.IsMinEnabled;
            _requiredTotalsColumn = _hasTotals &&
                                    FirstColumn != null &&
                                    (FirstColumn.IsSumEnabled || FirstColumn.IsAverageEnabled ||
                                     FirstColumn.IsMaxEnabled || FirstColumn.IsMinEnabled);

            if (_hasSubGrid && IsSubGridVisible == null)
            {
                IsSubGridVisible = new bool[Grid.DisplayingItemsCount];
                for (int i = 0; i < IsSubGridVisible.Length; i++)
                {
                    IsSubGridVisible[i] = false;
                }
            }
            if (_hasSubGrid && InitSubGrid == null)
            {
                InitSubGrid = new bool[Grid.DisplayingItemsCount];
                for (int i = 0; i < InitSubGrid.Length; i++)
                {
                    InitSubGrid[i] = true;
                }
            }
        }
        protected override void OnParametersSet()
        {
            _filterComponents = new QueryDictionary <Type>();
            _filterComponents.Add("System.String", typeof(TextFilterComponent <T>));
            _filterComponents.Add("System.Int32", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.Double", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.Decimal", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.Byte", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.Single", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.Float", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.Int64", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.Int16", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.UInt64", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.UInt32", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.UInt16", typeof(NumberFilterComponent <T>));
            _filterComponents.Add("System.DateTime", typeof(DateTimeFilterComponent <T>));
            _filterComponents.Add("System.Date", typeof(DateTimeFilterComponent <T>));
            _filterComponents.Add("System.DateTimeOffset", typeof(DateTimeFilterComponent <T>));
            _filterComponents.Add("System.Boolean", typeof(BooleanFilterComponent <T>));

            if (CustomFilters != null)
            {
                foreach (var widget in CustomFilters)
                {
                    if (_filterComponents.ContainsKey(widget.Key))
                    {
                        _filterComponents[widget.Key] = widget.Value;
                    }
                    else
                    {
                        _filterComponents.Add(widget);
                    }
                }
            }

            FirstColumn = (ICGridColumn)Grid.Columns.FirstOrDefault();

            _hasSubGrid           = Grid.SubGridKeys != null && Grid.SubGridKeys.Length > 0;
            _hasTotals            = Grid.IsSumEnabled || Grid.IsAverageEnabled || Grid.IsMaxEnabled || Grid.IsMinEnabled;
            _requiredTotalsColumn = _hasTotals &&
                                    FirstColumn != null &&
                                    (FirstColumn.IsSumEnabled || FirstColumn.IsAverageEnabled ||
                                     FirstColumn.IsMaxEnabled || FirstColumn.IsMinEnabled);

            InitSubGridVars();

            var queryBuilder          = new CustomQueryStringBuilder(Grid.Settings.SearchSettings.Query);
            var exceptQueryParameters = new List <string> {
                GridPager.DefaultPageSizeQueryParameter
            };

            _changePageSizeUrl = queryBuilder.GetQueryStringExcept(exceptQueryParameters);
            _pageSize          = Grid.Pager.ChangePageSize && Grid.Pager.QueryPageSize > 0 ? Grid.Pager.QueryPageSize : Grid.Pager.PageSize;
        }