Esempio n. 1
0
        protected override void OnParametersSet()
        {
            //determine current column filter settings
            _filterSettings = new List <ColumnFilterValue>();
            if (FilterSettings.IsInitState(Column) && Column.InitialFilterSettings != ColumnFilterValue.Null)
            {
                _filterSettings.Add(Column.InitialFilterSettings);
            }
            else
            {
                _filterSettings.AddRange(FilterSettings.FilteredColumns.GetByColumn(Column));
            }

            _isColumnFiltered = _filterSettings.Any(r => r.FilterType != GridFilterType.Condition);

            //determine current url:
            var queryBuilder = new CustomQueryStringBuilder(FilterSettings.Query);

            var exceptQueryParameters = new List <string>
            {
                QueryStringFilterSettings.DefaultTypeQueryParameter,
                QueryStringFilterSettings.DefaultClearInitFilterQueryParameter
            };
            string pagerParameterName = GetPagerQueryParameterName(((ICGrid)(Column.ParentGrid)).Pager);

            if (!string.IsNullOrEmpty(pagerParameterName))
            {
                exceptQueryParameters.Add(pagerParameterName);
            }

            _url = queryBuilder.GetQueryStringExcept(exceptQueryParameters);

            _clearInitFilter = FilterSettings.Query.Get(QueryStringFilterSettings.DefaultClearInitFilterQueryParameter);

            if (Column.Hidden)
            {
                _cssStyles = ((GridStyledColumn)Column).GetCssStylesString() + " " + ThStyle;
            }
            else
            {
                _cssStyles = ((GridStyledColumn)Column).GetCssStylesString();
            }
            _cssClass = ((GridStyledColumn)Column).GetCssClassesString() + " " + ThClass;

            if (GridComponent.Grid.Direction == GridDirection.RTL)
            {
                _cssStyles = string.Concat(_cssStyles, " text-align:right;direction:rtl;").Trim();
            }

            // tables with fixed layout don't need to set up column width on the header
            if (GridComponent.Grid.TableLayout == TableLayout.Auto)
            {
                if (!string.IsNullOrWhiteSpace(Column.Width))
                {
                    _cssStyles = string.Concat(_cssStyles, " width:", Column.Width, ";").Trim();
                }
            }

            List <string> cssFilterClasses = new List <string>();

            cssFilterClasses.Add(FilterButtonCss);
            if (_isColumnFiltered)
            {
                cssFilterClasses.Add(FilteredButtonCssClass);
            }
            _cssFilterClass = string.Join(" ", cssFilterClasses);

            List <string> cssSortingClass = new List <string>();

            cssSortingClass.Add("grid-header-title");

            if (Column.IsSorted)
            {
                cssSortingClass.Add("sorted");
                cssSortingClass.Add(Column.Direction == GridSortDirection.Ascending ? "sorted-asc" : "sorted-desc");
            }
            _cssSortingClass = string.Join(" ", cssSortingClass);

            if (Column.FilterEnabled)
            {
                FilterWidgetRender = CreateFilterWidgetComponent();
            }

            if (!string.IsNullOrWhiteSpace(Column.Name))
            {
                GridComponent.HeaderComponents.AddParameter(Column.Name, this);
            }
        }
        protected override void OnParametersSet()
        {
            //determine current column filter settings
            _filterSettings = new List <ColumnFilterValue>();
            if (FilterSettings.IsInitState(Column) && Column.InitialFilterSettings != ColumnFilterValue.Null)
            {
                _filterSettings.Add(Column.InitialFilterSettings);
            }
            else
            {
                _filterSettings.AddRange(FilterSettings.FilteredColumns.GetByColumn(Column));
            }

            _isColumnFiltered = _filterSettings.Any();

            //determine current url:
            var queryBuilder = new CustomQueryStringBuilder(FilterSettings.Query);

            var exceptQueryParameters = new List <string>
            {
                QueryStringFilterSettings.DefaultTypeQueryParameter,
                QueryStringFilterSettings.DefaultClearInitFilterQueryParameter
            };
            string pagerParameterName = GetPagerQueryParameterName(((ICGrid <T>)(Column.ParentGrid)).Pager);

            if (!string.IsNullOrEmpty(pagerParameterName))
            {
                exceptQueryParameters.Add(pagerParameterName);
            }

            _url = queryBuilder.GetQueryStringExcept(exceptQueryParameters);

            _clearInitFilter = FilterSettings.Query.Get(QueryStringFilterSettings.DefaultClearInitFilterQueryParameter);

            if (((GridColumnBase <T>)Column).Hidden)
            {
                _cssStyles = ((GridStyled)Column).GetCssStylesString() + " " + ThStyle;
            }
            else
            {
                _cssStyles = ((GridStyled)Column).GetCssStylesString();
            }
            _cssClass = ((GridStyled)Column).GetCssClassesString() + " " + ThClass;

            if (!string.IsNullOrWhiteSpace(Column.Width))
            {
                _cssStyles = string.Concat(_cssStyles, " width:", Column.Width, ";").Trim();
            }
            ;

            List <string> cssFilterClasses = new List <string>();

            cssFilterClasses.Add(FilterButtonCss);
            if (_isColumnFiltered)
            {
                cssFilterClasses.Add(FilteredButtonCssClass);
            }
            _cssFilterClass = string.Join(" ", cssFilterClasses);

            List <string> cssSortingClass = new List <string>();

            cssSortingClass.Add("grid-header-title");

            if (Column.IsSorted)
            {
                cssSortingClass.Add("sorted");
                cssSortingClass.Add(Column.Direction == GridSortDirection.Ascending ? "sorted-asc" : "sorted-desc");
            }
            _cssSortingClass = string.Join(" ", cssSortingClass);

            FilterWidgetRender = CreateFilterWidgetComponent();
        }