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) { 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 = (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; }
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; 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>(this, _columnBuilder, _settings.SortSettings); ComponentOptions = new GridOptions(); ApplyGridSettings(); Pager = new GridPager(query); ComponentOptions.RenderRowsOnly = renderOnlyRows; columns?.Invoke(Columns); }
public void Init() { _query = QueryDictionary <StringValues> .Convert((new DefaultHttpContext()).Request.Query); _repo = new TestRepository(); _grid = new TestGrid(_repo.GetAll()); }
public async Task UpdateFiles(Employee item, IQueryDictionary <IFileListEntry[]> files) { if (files.Count > 0) { var file = files.FirstOrDefault(); if (file.Value.Length > 0) { var ms = new MemoryStream(); await file.Value[0].Data.CopyToAsync(ms); byte[] ba = new byte[ms.Length + 78]; for (int i = 0; i < 78; i++) { ba[i] = 0; } Array.Copy(ms.ToArray(), 0, ba, 78, ms.Length); item.Photo = ba; using (var context = new NorthwindDbContext(_options)) { try { var repository = new EmployeeRepository(context); await repository.Update(item); repository.Save(); } catch (Exception e) { throw new GridException(e); } } } } }
public GridPager(IQueryDictionary <StringValues> query) { if (query == null) { throw new Exception("No http context here!"); } _query = query; _currentPage = -1; _queryBuilder = new CustomQueryStringBuilder(query); ParameterName = DefaultPageQueryParameter; TemplateName = DefaultPagerViewName; MaxDisplayedPages = MaxDisplayedPages; string pageSizeParameter = query.Get(DefaultPageSizeQueryParameter); int pageSize = 0; if (pageSizeParameter != null) { int.TryParse(pageSizeParameter, out pageSize); } QueryPageSize = pageSize; PageSize = DefaultPageSize; }
public QueryStringGridSettingsProvider(IQueryDictionary <StringValues> query) { _sortSettings = new QueryStringSortSettings(query); //add additional header renderer for filterable columns: _filterSettings = new QueryStringFilterSettings(query); _searchSettings = new QueryStringSearchSettings(query); }
public GridClient(string url, IQueryDictionary <StringValues> query, bool renderOnlyRows, string gridName, Action <IGridColumnCollection <T> > columns = null, CultureInfo cultureInfo = null) { _source = new CGrid <T>(url, query, renderOnlyRows, columns, cultureInfo); Named(gridName); //WithPaging(_source.Pager.PageSize); }
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); } } } }
public QueryStringSortSettings(IQueryDictionary <StringValues> query) { if (query == null) { throw new ArgumentException("No http context here!"); } Query = query; ColumnQueryParameterName = DefaultColumnQueryParameter; DirectionQueryParameterName = DefaultDirectionQueryParameter; var sortings = query.Get(ColumnOrderValue.DefaultSortingQueryParameter); if (sortings.Count > 0) { foreach (string sorting in sortings) { ColumnOrderValue column = QueryDictionary <StringValues> .CreateColumnData(sorting); if (column != ColumnOrderValue.Null) { _sortValues.Add(column); } } } }
public async Task <Employee> UpdateFiles(Employee item, IQueryDictionary <IFileListEntry[]> files) { if (files.Count > 0) { var file = files.FirstOrDefault(); if (file.Value.Length > 0) { // add OLE header to file data byte array var ms = new MemoryStream(); await file.Value[0].Data.CopyToAsync(ms); byte[] ba = new byte[ms.Length + 78]; for (int i = 0; i < 78; i++) { ba[i] = 0; } Array.Copy(ms.ToArray(), 0, ba, 78, ms.Length); // convert byte array to url scaped base64 string base64Str = Convert.ToBase64String(ba); base64Str = base64Str.Replace('+', '.'); base64Str = base64Str.Replace('/', '_'); base64Str = base64Str.Replace('=', '-'); item.Base64String = base64Str; var response = await _httpClient.PostAsJsonAsync(_baseUri + $"api/SampleData/SetEmployeePhoto", item); if (!response.IsSuccessStatusCode) { throw new GridException("EMPSRV-04", "Error updating the employee"); } } } return(item); }
public CGrid(Func <QueryDictionary <StringValues>, Task <ItemsDTO <T> > > dataServiceAsync, IQueryDictionary <StringValues> query, bool renderOnlyRows, Action <IGridColumnCollection <T> > columns = null, CultureInfo cultureInfo = null, IColumnBuilder <T> columnBuilder = null) : this(null, null, null, dataServiceAsync, query, renderOnlyRows, columns, cultureInfo, columnBuilder) { }
public SGrid(IEnumerable <T> items, IQueryCollection query) : base(items) { #region init default properties _query = QueryDictionary <StringValues> .Convert(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); _annotations = new GridAnnotationsProvider(); #endregion //Set up column collection: _columnBuilder = new DefaultColumnBuilder <T>(this, _annotations); _columnsCollection = new GridColumnCollection <T>(this, _columnBuilder, _settings.SortSettings); RenderOptions = new GridRenderOptions(); ApplyGridSettings(); }
public static NameValueCollection Convert(IQueryDictionary <StringValues> collection) { NameValueCollection nameValueCollection = new NameValueCollection(); foreach (var element in collection) { nameValueCollection.Set(element.Key, element.Value); } return(nameValueCollection); }
public QueryStringSortSettings(IQueryDictionary <StringValues> query) { if (query == null) { throw new ArgumentException("No http context here!"); } Query = query; ColumnQueryParameterName = DefaultColumnQueryParameter; DirectionQueryParameterName = DefaultDirectionQueryParameter; }
public GridPager() { _query = new QueryDictionary <StringValues>(); _currentPage = -1; _queryBuilder = new CustomQueryStringBuilder(_query); ParameterName = DefaultPageQueryParameter; MaxDisplayedPages = MaxDisplayedPages; PageSize = DefaultPageSize; }
public GridODataClient(HttpClient httpClient, string url, IQueryDictionary<StringValues> query, bool renderOnlyRows, string gridName, Action<IGridColumnCollection<T>> columns = null, int? pageSize = null, CultureInfo cultureInfo = null, IEnumerable<string> oDataExpandList = null, IColumnBuilder<T> columnBuilder = null) : base(httpClient, url, query, renderOnlyRows, gridName, columns, cultureInfo, columnBuilder) { UseServerAPI(ServerAPI.OData); if (pageSize.HasValue) WithPaging(pageSize.Value); if (oDataExpandList != null) UseODataExpand(oDataExpandList); }
public QueryStringSearchSettings(IQueryDictionary <StringValues> query) { if (query == null) { throw new ArgumentException("No http context here!"); } Query = query; string[] search = Query.Count > 0 ? Query.Get(DefaultSearchQueryParameter).ToArray() : null; if (search != null && search.Length > 0) { _searchValue = search[0]; } }
public QueryStringSearchSettings(IQueryDictionary <StringValues> query) { if (query == null) { throw new ArgumentException("No http context here!"); } Query = query; var search = Query.Get(DefaultSearchQueryParameter); if (search.Count > 0) { _searchValue = search[0]; } }
public GridPager(IQueryDictionary <StringValues> query) { if (query == null) { throw new Exception("No http context here!"); } _query = query; _currentPage = -1; _queryBuilder = new CustomQueryStringBuilder(query); ParameterName = DefaultPageQueryParameter; TemplateName = DefaultPagerViewName; MaxDisplayedPages = MaxDisplayedPages; PageSize = DefaultPageSize; }
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; }
public QueryStringFilterSettings(IQueryDictionary <StringValues> query) { if (query == null) { throw new ArgumentException("No http context here!"); } Query = query; string[] filters = Query.Count > 0 ? Query.Get(DefaultTypeQueryParameter).ToArray() : null; if (filters != null) { foreach (string filter in filters) { ColumnFilterValue column = CreateColumnData(filter); if (column != ColumnFilterValue.Null) { _filterValues.Add(column); } } } }
public GridPager(IQueryDictionary <StringValues> query) { _query = new QueryDictionary <StringValues>(); _currentPage = -1; _queryBuilder = new CustomQueryStringBuilder(_query); ParameterName = DefaultPageQueryParameter; MaxDisplayedPages = MaxDisplayedPages; PageSize = DefaultPageSize; _query = query; _queryBuilder = new CustomQueryStringBuilder(_query); string pageSizeParameter = query.Get(DefaultPageSizeQueryParameter); int pageSize = 0; if (pageSizeParameter != null) { int.TryParse(pageSizeParameter, out pageSize); } QueryPageSize = pageSize; }
public async Task <Employee> UpdateFiles(Employee item, IQueryDictionary <IFileListEntry[]> files) { if (files.Count > 0) { var file = files.FirstOrDefault(); if (file.Value.Length > 0) { // add OLE header to file data byte array var ms = new MemoryStream(); await file.Value[0].Data.CopyToAsync(ms); byte[] ba = new byte[ms.Length + 78]; for (int i = 0; i < 78; i++) { ba[i] = 0; } Array.Copy(ms.ToArray(), 0, ba, 78, ms.Length); item.Photo = ba; await _employeeService.Update(item); } } return(item); }
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)>(); }
public CGrid(string url, IQueryDictionary <StringValues> query, bool renderOnlyRows, Action <IGridColumnCollection <T> > columns = null, CultureInfo cultureInfo = null, IColumnBuilder <T> columnBuilder = null) : this(null, url, null, null, query, renderOnlyRows, columns, cultureInfo, columnBuilder) { }
public GridPager(IQueryDictionary <StringValues> query) : this() { _query = query; _queryBuilder = new CustomQueryStringBuilder(_query); }
public GridPager(IQueryDictionary <StringValues> query, int page) : this(query) { CurrentPage = page; }
public async Task InsertFiles(Employee item, IQueryDictionary <IFileListEntry[]> files) { await UpdateFiles(item, files); }
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; } } }
public CustomQueryStringBuilder(IQueryDictionary <StringValues> collection) : base(Convert(collection)) { }