Exemple #1
0
        public async Task <ItemsDTO <Order> > GetOrdersGridRowsInMemory(Action <IGridColumnCollection <Order> > columns,
                                                                        QueryDictionary <StringValues> query)
        {
            /**
             * var server = new GridServer<Order>(await GetAll(), new QueryCollection(query), true, "ordersGrid", columns)
             *          .Sortable()
             *          .WithPaging(10)
             *          .Filterable()
             *          .WithMultipleFilters()
             *          .Groupable(true)
             *          .Searchable(true, false, false);
             *
             * // return items to displays
             * var items = server.ItemsToDisplay;
             */
            var items = new ItemsDTO <Order>();

            return(items);
        }
Exemple #2
0
        public ItemsDTO <Customer> GetCustomersGridRows(Action <IGridColumnCollection <Customer> > columns,
                                                        QueryDictionary <StringValues> query)
        {
            using (var context = new NorthwindDbContext(_options))
            {
                var repository = new CustomersRepository(context);
                var server     = new GridServer <Customer>(repository.GetAll(), new QueryCollection(query),
                                                           true, "customersGrid", columns)
                                 .Sortable()
                                 .WithPaging(10)
                                 .Filterable()
                                 .WithMultipleFilters()
                                 .Searchable(true, false);

                // return items to displays
                var items = server.ItemsToDisplay;
                return(items);
            }
        }
        public void TestExcept()
        {
            QueryDictionary <StringValues> query = new QueryDictionary <StringValues>();

            query.Add("key1", "value1");
            query.Add("key2", "value2");

            _builder = new CustomQueryStringBuilder(query);

            var str1 = _builder.GetQueryStringExcept(new[] { "key1" });

            Assert.AreEqual(str1, "?key2=value2");

            str1 = _builder.GetQueryStringExcept(new[] { "key2" });
            Assert.AreEqual(str1, "?key1=value1");

            str1 = _builder.GetQueryStringExcept(new[] { "key1", "key2" });
            Assert.AreEqual(str1, string.Empty);
        }
Exemple #4
0
        public ItemsDTO <Order> GetOrdersGridRows(Action <IGridColumnCollection <Order> > columns,
                                                  QueryDictionary <StringValues> query)
        {
            var server = new GridServer <Order>(_orderRepository.All, new QueryCollection(query),
                                                true, "ordersGrid", columns, 10)
                         .Sortable()
                         .Filterable()
                         .WithMultipleFilters()
                         .Searchable(true, false);

            // return items to displays
            var items = server.ItemsToDisplay;

            // uncomment the following lines are to test null responses
            //items = null;
            //items.Items = null;
            //items.Pager = null;
            return(items);
        }
Exemple #5
0
        public CGrid(string url, IQueryDictionary <StringValues> query, bool renderOnlyRows,
                     Action <IGridColumnCollection <T> > columns = null, CultureInfo cultureInfo = null)
        {
            _dataService      = null;
            _dataServiceAsync = null;

            Items          = new List <T>();
            _selectedItems = new List <object>();

            _httpClient = null;
            Url         = url;
            _query      = query as QueryDictionary <StringValues>;

            //set up sort settings:
            _settings = new QueryStringGridSettingsProvider(_query);
            Sanitizer = new Sanitizer();
            if (cultureInfo != null)
            {
                Strings.Culture = cultureInfo;
            }
            EmptyGridText = Strings.DefaultGridEmptyText;
            Language      = Strings.Lang;

            _annotations = new GridAnnotationsProvider();

            //Set up column collection:
            _columnBuilder     = new DefaultColumnBuilder <T>(this, _annotations);
            _columnsCollection = new GridColumnCollection <T>(this, _columnBuilder, _settings.SortSettings);
            ComponentOptions   = new GridOptions();

            ApplyGridSettings();

            Pager = new GridPager(query);

            ComponentOptions.RenderRowsOnly = renderOnlyRows;
            columns?.Invoke(Columns);

            Mode          = GridMode.Grid;
            CreateEnabled = false;
            ReadEnabled   = false;
            UpdateEnabled = false;
            DeleteEnabled = false;
        }
Exemple #6
0
        public SGridCore(IEnumerable <T> items, QueryDictionary <StringValues> query, IColumnBuilder <T> columnBuilder = null)
            : this()
        {
            BeforeItems = items.AsQueryable();

            #region init default properties

            Query = query;

            //set up sort settings:
            _settings = new QueryStringGridSettingsProvider(Query);

            Sanitizer     = new Sanitizer();
            EmptyGridText = Strings.DefaultGridEmptyText;
            Language      = Strings.Lang;

            _currentSortItemsProcessor   = new SortGridItemsProcessor <T>(this, _settings.SortSettings);
            _currentFilterItemsProcessor = new FilterGridItemsProcessor <T>(this, _settings.FilterSettings);
            _currentSearchItemsProcessor = new SearchGridItemsProcessor <T>(this, _settings.SearchSettings);
            _currentTotalsItemsProcessor = new TotalsGridItemsProcessor <T>(this);
            AddItemsPreProcessor(_currentFilterItemsProcessor);
            AddItemsPreProcessor(_currentSearchItemsProcessor);
            InsertItemsProcessor(0, _currentSortItemsProcessor);
            SetTotalsProcessor(_currentTotalsItemsProcessor);

            #endregion init default properties

            _annotations = new GridCoreAnnotationsProvider();

            //Set up column collection:
            if (columnBuilder == null)
            {
                _columnBuilder = new DefaultColumnCoreBuilder <T>(this, _annotations);
            }
            else
            {
                _columnBuilder = columnBuilder;
            }
            _columnsCollection = new GridColumnCollection <T>(this, _columnBuilder, _settings.SortSettings);
            RenderOptions      = new GridRenderOptions();

            ApplyGridSettings();
        }
Exemple #7
0
        public ItemsDTO <Order> GetOrdersGridRowsInMemory(Action <IGridColumnCollection <Order> > columns,
                                                          QueryDictionary <StringValues> query)
        {
            using (var context = new NorthwindDbContext(_options))
            {
                var repository = new OrdersRepository(context);
                var server     = new GridCoreServer <Order>(repository.GetAll().ToList(), query, true, "ordersGrid", columns)
                                 .Sortable()
                                 .WithPaging(10)
                                 .Filterable()
                                 .WithMultipleFilters()
                                 .Groupable(true)
                                 .Searchable(true, false, false);

                // return items to displays
                var items = server.ItemsToDisplay;
                return(items);
            }
        }
        public ItemsDTO <Order> GetOrdersGridRows(QueryDictionary <StringValues> query)
        {
            using (var context = new NorthwindDbContext(_options))
            {
                var repository = new OrdersRepository(context);
                var server     = new GridServer <Order>(repository.GetAll(), new QueryCollection(query),
                                                        true, "ordersGrid", null)
                                 .AutoGenerateColumns()
                                 .Sortable()
                                 .WithPaging(10)
                                 .Filterable()
                                 .WithMultipleFilters()
                                 .Groupable(true)
                                 .Searchable(true, false, false);

                // return items to displays
                return(server.ItemsToDisplay);
            }
        }
Exemple #9
0
        public SGridCore(IEnumerable <T> items, QueryDictionary <StringValues> query, bool renderOnlyRows,
                         string pagerViewName = GridPager.DefaultPagerViewName, IColumnBuilder <T> columnBuilder = null)
            : this(items, query, columnBuilder)
        {
            var    urlParameters = CustomQueryStringBuilder.Convert(query);
            string pageParameter = urlParameters[((GridPager)Pager).ParameterName];
            int    page          = 0;

            if (pageParameter != null)
            {
                int.TryParse(pageParameter, out page);
            }
            if (page == 0)
            {
                page++;
            }
            ((GridPager)_pager).CurrentPage  = page;
            ((GridPager)_pager).TemplateName = pagerViewName;
            RenderOptions.RenderRowsOnly     = renderOnlyRows;
        }
 private void InitCheckboxAndSubGridVars()
 {
     Checkboxes = new QueryDictionary <Dictionary <int, CheckboxComponent <T> > >();
     if (_hasSubGrid)
     {
         IsSubGridVisible = new bool[Grid.Pager.PageSize];
         for (int i = 0; i < IsSubGridVisible.Length; i++)
         {
             IsSubGridVisible[i] = false;
         }
     }
     if (_hasSubGrid)
     {
         InitSubGrid = new bool[Grid.Pager.PageSize];
         for (int i = 0; i < InitSubGrid.Length; i++)
         {
             InitSubGrid[i] = true;
         }
     }
 }
        public ItemsDTO <OrderDetail> GetOrderDetailsGridRows(Action <IGridColumnCollection <OrderDetail> > columns,
                                                              object[] keys, QueryDictionary <StringValues> query)
        {
            using (var context = new NorthwindDbContext(_options))
            {
                int orderId;
                int.TryParse(keys[0].ToString(), out orderId);
                var repository = new OrderDetailsRepository(context);
                var server     = new GridServer <OrderDetail>(repository.GetForOrder(orderId), new QueryCollection(query),
                                                              true, "orderDetailssGrid" + keys[0].ToString(), columns)
                                 .Sortable()
                                 .WithPaging(10)
                                 .Filterable()
                                 .WithMultipleFilters();

                // return items to displays
                var items = server.ItemsToDisplay;
                return(items);
            }
        }
 protected async Task CreateItem()
 {
     try
     {
         Error        = "";
         ColumnErrors = new QueryDictionary <string>();
         await GridComponent.CreateItem(this);
     }
     catch (GridException e)
     {
         _shouldRender = true;
         Error         = string.IsNullOrWhiteSpace(e.Code) ? e.Message : e.Code + " - " + e.Message;
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         _shouldRender = true;
         Error         = Strings.CreateError;
     }
 }
Exemple #13
0
        public ItemsDTO <Employee> GetEmployeesGridRows(Action <IGridColumnCollection <Employee> > columns,
                                                        QueryDictionary <StringValues> query)
        {
            using (var context = new NorthwindDbContext(_options))
            {
                var repository = new EmployeeRepository(context);
                var server     = new GridCoreServer <Employee>(repository.GetAll(), query, true, "employeesGrid", columns)
                                 .Sortable()
                                 .WithPaging(10)
                                 .Filterable()
                                 .WithMultipleFilters()
                                 .Groupable(true)
                                 .Searchable(true, false, false)
                                 .SetRemoveDiacritics <NorthwindDbContext>("RemoveDiacritics");

                // return items to displays
                var items = server.ItemsToDisplay;
                return(items);
            }
        }
Exemple #14
0
        protected override async Task OnParametersSetAsync()
        {
            AddEventHandlers();

            configs        = ConfigService.Configs.OrderByDescending(c => c.Metadata.LastModified).ToList();
            selectedConfig = ConfigService.SelectedConfig;

            Action <IGridColumnCollection <Config> > columns = c =>
            {
                c.Add(x => x.Metadata.Name).Titled(Loc["Name"]).Encoded(false).Sanitized(false)
                .RenderValueAs(x => $"<div class=\"grid-element-with-icon\"><img src=\"data:image/png;base64,{x.Metadata.Base64Image}\"/><span>{x.Metadata.Name}</span></div>");
                c.Add(x => x.Metadata.Author).Titled(Loc["Author"]);
                c.Add(x => x.Metadata.Category).Titled(Loc["Category"]);
                c.Add(x => x.IsRemote).Titled(Loc["Remote"]);
                c.Add(x => x.Settings.ProxySettings.UseProxies).Titled(Loc["Proxies"]);
                c.Add(x => x.Settings.DataSettings.AllowedWordlistTypesString).Titled(Loc["Wordlists"]);
                c.Add(x => x.Metadata.CreationDate).Titled(Loc["CreationDate"]).SetFilterWidgetType("DateTimeLocal").Format("{0:dd/MM/yyyy HH:mm}");
                c.Add(x => x.Metadata.LastModified).Titled(Loc["LastModified"]).SetFilterWidgetType("DateTimeLocal").Format("{0:dd/MM/yyyy HH:mm}")
                .Sortable(true).SortInitialDirection(GridShared.Sorting.GridSortDirection.Descending);
            };

            var query = new QueryDictionary <StringValues>();

            query.Add("grid-page", "1");

            var client = new GridClient <Config>(q => GetGridRows(columns, q), query, false, "configsGrid", columns, CultureInfo.CurrentCulture)
                         .Sortable()
                         .ExtSortable()
                         .Filterable()
                         .WithMultipleFilters()
                         .SetKeyboard(true)
                         .ChangePageSize(true)
                         .WithGridItemsCount()
                         .Selectable(true, false, false);

            grid = client.Grid;

            // Try to set a previous filter
            if (VolatileSettings.GridQueries.ContainsKey((0, "configsGrid")))
            {
                grid.Query = VolatileSettings.GridQueries[(0, "configsGrid")];
Exemple #15
0
 public async Task <decimal?> GetMinFreight(string clientName, QueryDictionary <StringValues> query)
 {
     using (var context = new NorthwindDbContext(_options))
     {
         try
         {
             var repository = new OrdersRepository(context);
             var server     = new GridCoreServer <Order>(repository.GetForClient(clientName), query, true, "ordersGrid", null)
                              .AutoGenerateColumns()
                              .Sortable()
                              .Filterable()
                              .WithMultipleFilters()
                              .SetRemoveDiacritics <NorthwindDbContext>("RemoveDiacritics");
             return(await Task.FromResult(server.ItemsToDisplay.Items.Min(r => r.Freight)));
         }
         catch (Exception)
         {
             throw new GridException("Error etting min freight");
         }
     }
 }
Exemple #16
0
        public ItemsDTO <Order> GetOrdersGridRows(Action <IGridColumnCollection <Order> > columns,
                                                  QueryDictionary <StringValues> query)
        {
            using (var context = new NorthwindDbContext(_options))
            {
                var repository = new OrdersRepository(context);
                var server     = new GridServer <Order>(repository.GetAll().Include(r => r.OrderDetails), new QueryCollection(query),
                                                        true, "ordersGrid", columns)
                                 .Sortable()
                                 .WithPaging(10)
                                 .Filterable()
                                 .WithMultipleFilters()
                                 .Groupable(true)
                                 .Searchable(true, false, false)
                                 .SetRemoveDiacritics <NorthwindDbContext>("RemoveDiacritics");

                // return items to displays
                var items = server.ItemsToDisplay;
                return(items);
            }
        }
        protected override void OnParametersSet()
        {
            _renderFragments = new QueryDictionary <RenderFragment>();
            foreach (var column in GridComponent.Grid.Columns)
            {
                // Name must have a non empty value
                if (string.IsNullOrWhiteSpace(column.Name))
                {
                    column.Name = Guid.NewGuid().ToString();
                }

                if (column.CreateComponentType != null)
                {
                    _renderFragments.Add(column.Name, GridCellComponent <T> .CreateComponent(_sequence,
                                                                                             column.CreateComponentType, column, Item));
                }
            }
            _tabGroups = GridComponent.Grid.Columns
                         .Where(r => !string.IsNullOrWhiteSpace(r.TabGroup) && _renderFragments.Keys.Any(s => s.Equals(r.Name)))
                         .Select(r => r.TabGroup).Distinct();
        }
Exemple #18
0
        public CGrid(Func <QueryDictionary <StringValues>, ItemsDTO <T> > dataService,
                     QueryDictionary <StringValues> query, bool renderOnlyRows,
                     Action <IGridColumnCollection <T> > columns = null, CultureInfo cultureInfo = null)
        {
            _dataService = dataService;

            Items      = new List <T>(); //response.Items;
            ItemsCount = -1;             // Items.Count();

            Url    = null;
            _query = query;

            //set up sort settings:
            _settings = new QueryStringGridSettingsProvider(_query);
            Sanitizer = new Sanitizer();
            if (cultureInfo != null)
            {
                Strings.CultureInfo = cultureInfo;
            }
            EmptyGridText = Strings.DefaultGridEmptyText;
            Language      = Strings.Lang;

            _annotations = new GridAnnotaionsProvider();

            //Set up column collection:
            _columnBuilder     = new DefaultColumnBuilder <T>(this, _annotations);
            _columnsCollection = new GridColumnCollection <T>(_columnBuilder, _settings.SortSettings);
            ComponentOptions   = new GridOptions();

            ApplyGridSettings();

            //Pager = new GridPager(query, response.Pager.CurrentPage);
            //((GridPager)Pager).PageSize = response.Pager.PageSize;
            //((GridPager)Pager).ItemsCount = response.Pager.ItemsCount;

            Pager = new GridPager(query);

            ComponentOptions.RenderRowsOnly = renderOnlyRows;
            columns?.Invoke(Columns);
        }
Exemple #19
0
        protected override async Task OnInitializedAsync()
        {
            Action <IGridColumnCollection <CircleViewModel> > columns = c =>
            {
                c.Add(o => o.Id).Titled("Id").Sortable(true);
                c.Add(o => o.Name).Titled("Name").Sortable(true);
                c.Add(o => o.NumberOfUsers).Sortable(true);
                c.Add(o => o.NumberOfMessages).Sortable(true);
            };

            var query = new QueryDictionary <StringValues>();

            query.Add("grid-page", "1");

            var client = new GridClient <CircleViewModel>(q => CirclesGridService.GetRows(columns, q), query, false, "ordersGrid", columns);

            Grid = client.Grid;

            // Set new items to grid
            Task = client.UpdateGrid();
            await Task;
        }
        // Update --------------------------------

        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        /// <param name="tryMode"></param>
        /// <returns></returns>
        public IDbStoredQuery Query(string name, bool tryMode = true)
        {
            IDbStoredQuery query;

            try
            {
                if (tryMode)
                {
                    QueryDictionary.TryGetValue(name, out query);
                }
                else
                {
                    query = QueryDictionary[name]?.Clone <DbStoredQuery>();
                }
            }
            catch (KeyNotFoundException)
            {
                throw new DbModelException("Unknown query (name='" + name + "')");
            }

            return(query);
        }
Exemple #21
0
        protected override async Task OnInitializedAsync()
        {
            Action <IGridColumnCollection <UserViewModel> > columns = c =>
            {
                c.Add(o => o.Id).Titled("Id").Sortable(true);
                c.Add(o => o.UserName).Titled("Name").Sortable(true);
                c.Add(o => o.Email).Titled("Email").Sortable(true);
                c.Add().Titled("Ambassador").Encoded(false).Sanitized(false).SetWidth(30).RenderComponentAs(typeof(AmbassadorCell));
            };

            var query = new QueryDictionary <StringValues>();

            query.Add("grid-page", "1");

            var client = new GridClient <UserViewModel>(q => UsersGridService.GetRows(columns, q), query, false, "usersGrid", columns);

            Grid = client.Grid;

            // Set new items to grid
            Task = client.UpdateGrid();
            await Task;
        }
Exemple #22
0
        public ItemsDTO <Order> GetOrdersGridRowsWithCount(Action <IGridColumnCollection <Order> > columns,
                                                           QueryDictionary <StringValues> query)
        {
            using (var context = new NorthwindDbContext(_options))
            {
                var repository = new OrdersRepository(context);
                var server     = new GridCoreServer <Order>(repository.GetAll().Include(r => r.OrderDetails), query, true, "ordersGrid", columns)
                                 .Sortable()
                                 .WithPaging(10)
                                 .Filterable()
                                 .WithMultipleFilters()
                                 .Groupable(true)
                                 .Searchable(true, false, false);

                // return items to displays
                var items = server.ItemsToDisplay;

                // uncomment the following lines are to test null responses
                //items = null;
                //items.Items = null;
                //items.Pager = null;
                return(items);
            }
        }
Exemple #23
0
        protected override async Task OnParametersSetAsync()
        {
            _renderFragments = new QueryDictionary <RenderFragment>();
            foreach (var column in GridComponent.Grid.Columns)
            {
                // Name must have a non empty value
                if (string.IsNullOrWhiteSpace(column.Name))
                {
                    column.Name = Guid.NewGuid().ToString();
                }

                if (((ICGridColumn)column).SubGrids != null)
                {
                    var values = ((ICGridColumn)column).GetSubGridKeyValues(Item);
                    var grid   = await((ICGridColumn)column).SubGrids(values.Values.ToArray(), false, true, false, true) as ICGrid;
                    grid.Direction   = GridComponent.Grid.Direction;
                    grid.FixedValues = values;
                    VariableReference reference = new VariableReference();
                    if (Children.ContainsKey(column.Name))
                    {
                        Children[column.Name] = reference;
                    }
                    else
                    {
                        Children.Add(column.Name, reference);
                    }
                    if (_renderFragments.ContainsKey(column.Name))
                    {
                        _renderFragments[column.Name] = CreateSubGridComponent(grid, reference);
                    }
                    else
                    {
                        _renderFragments.Add(column.Name, CreateSubGridComponent(grid, reference));
                    }
                }
                else if (column.DeleteComponentType != null)
                {
                    VariableReference reference = new VariableReference();
                    if (Children.ContainsKey(column.Name))
                    {
                        Children[column.Name] = reference;
                    }
                    else
                    {
                        Children.Add(column.Name, reference);
                    }
                    if (_renderFragments.ContainsKey(column.Name))
                    {
                        _renderFragments[column.Name] = GridCellComponent <T> .CreateComponent(_sequence,
                                                                                               GridComponent, column.DeleteComponentType, column, Item, null, true, reference);
                    }
                    else
                    {
                        _renderFragments.Add(column.Name, GridCellComponent <T> .CreateComponent(_sequence,
                                                                                                 GridComponent, column.DeleteComponentType, column, Item, null, true, reference));
                    }
                }
            }
            _tabGroups = GridComponent.Grid.Columns
                         .Where(r => !string.IsNullOrWhiteSpace(r.TabGroup) && _renderFragments.Keys.Any(s => s.Equals(r.Name)))
                         .Select(r => r.TabGroup).Distinct();

            if (((CGrid <T>)GridComponent.Grid).ButtonCrudComponents != null && ((CGrid <T>)GridComponent.Grid).ButtonCrudComponents.Count() > 0)
            {
                foreach (var key in ((CGrid <T>)GridComponent.Grid).ButtonCrudComponents.Keys)
                {
                    var buttonCrudComponent = ((CGrid <T>)GridComponent.Grid).ButtonCrudComponents.Get(key);
                    if ((buttonCrudComponent.DeleteMode != null && buttonCrudComponent.DeleteMode(Item)) ||
                        (buttonCrudComponent.DeleteModeAsync != null && await buttonCrudComponent.DeleteModeAsync(Item)) ||
                        (buttonCrudComponent.GridMode.HasFlag(GridMode.Delete)))
                    {
                        _buttonCrudComponentVisibility.Add(key, true);
                    }
                    else
                    {
                        _buttonCrudComponentVisibility.Add(key, false);
                    }
                }
            }

            _shouldRender = true;
        }
        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;
        }
        public void Init()
        {
            HttpContext context = new DefaultHttpContext();

            _pager = new GridPager(QueryDictionary <StringValues> .Convert(context.Request.Query));
        }
Exemple #26
0
        public ItemsDTO <Shipper> GetShippersGridRows(Action <IGridColumnCollection <Shipper> > columns, QueryDictionary <StringValues> query)
        {
            var server = new GridCoreServer <Shipper>(Shippers, query, true, "shippersGrid", columns)
                         .WithPaging(10)
                         .Sortable()
                         .Filterable()
                         .WithMultipleFilters()
                         .WithGridItemsCount()
                         .Groupable(true)
                         .Searchable(true, false, false)
                         .SetRemoveDiacritics <StringUtils>("RemoveDiacritics");

            var items = server.ItemsToDisplay;

            return(items);
        }
Exemple #27
0
 virtual public void InitializeDictionaray()
 {
     queries = new QueryDictionary();
 }
 private void InitCheckedKeys()
 {
     // checked keys must be initialized only on component creation or after a filter or search change
     ExceptCheckedRows = new QueryDictionary <QueryDictionary <bool> >();
 }
Exemple #29
0
        private CGrid(HttpClient httpClient, string url,
                      Func <QueryDictionary <StringValues>, ItemsDTO <T> > dataService,
                      Func <QueryDictionary <StringValues>, Task <ItemsDTO <T> > > dataServiceAsync,
                      IQueryDictionary <StringValues> query, bool renderOnlyRows,
                      Action <IGridColumnCollection <T> > columns = null, CultureInfo cultureInfo = null,
                      IColumnBuilder <T> columnBuilder            = null)
        {
            _dataServiceAsync = dataServiceAsync;
            _dataService      = dataService;
            _selectedItems    = new List <object>();
            Items             = new List <T>(); //response.Items;

            Url         = url;
            _httpClient = httpClient;
            _query      = query as QueryDictionary <StringValues>;

            //set up sort settings:
            _settings = new QueryStringGridSettingsProvider(_query);
            Sanitizer = new Sanitizer();
            if (cultureInfo != null)
            {
                CultureInfo.CurrentCulture = cultureInfo;
            }
            EmptyGridText = Strings.DefaultGridEmptyText;
            Language      = Strings.Lang;

            _currentPagerODataProcessor  = new PagerGridODataProcessor <T>(this);
            _currentSortODataProcessor   = new SortGridODataProcessor <T>(this, _settings.SortSettings);
            _currentFilterODataProcessor = new FilterGridODataProcessor <T>(this, _settings.FilterSettings,
                                                                            _settings.SearchSettings);
            _currentSearchODataProcessor = new SearchGridODataProcessor <T>(this, _settings.SearchSettings);
            _currentExpandODataProcessor = new ExpandGridODataProcessor <T>(this);

            _annotations = new GridAnnotationsProvider();

            //Set up column collection:
            if (columnBuilder == null)
            {
                _columnBuilder = new DefaultColumnBuilder <T>(this, _annotations);
            }
            else
            {
                _columnBuilder = columnBuilder;
            }
            _columnsCollection = new GridColumnCollection <T>(this, _columnBuilder, _settings.SortSettings);
            ComponentOptions   = new GridOptions();

            ApplyGridSettings();

            Pager = new GridPager(query);

            ComponentOptions.RenderRowsOnly = renderOnlyRows;
            columns?.Invoke(Columns);

            Mode          = GridMode.Grid;
            CreateEnabled = false;
            ReadEnabled   = false;
            UpdateEnabled = false;
            DeleteEnabled = false;

            ButtonComponents = new QueryDictionary <(string Label, Nullable <MarkupString> Content, Type ComponentType,
                                                     IList <Action <object> > Actions, IList <Func <object, Task> > Functions, object Object)>();
        }
Exemple #30
0
 public SGridCore(IEnumerable <T> items, IQueryCollection query, IColumnBuilder <T> columnBuilder = null)
     : this(items, QueryDictionary <StringValues> .Convert(query), columnBuilder)
 {
 }