public static string PageInfoText(this ITableDataSet tableDataSet)
        {
            var from = tableDataSet.PageableOptions.CurrentPage * tableDataSet.PageableOptions.PageSize + 1;
            var to   = from + tableDataSet.PageableOptions.PageSize - 1;

            return($"{from} - {to}");
        }
 public static async Task GoToLastPage(this ITableDataSet tableDataSet)
 {
     if (!tableDataSet.PageableOptions.IsLastPage)
     {
         await tableDataSet.GoToPage(tableDataSet.PageableOptions.PagesCount - 1);
     }
 }
        public GridRendererContext(
            ImutableGridRendererContext imutableGridRendererContext,
            IRendererTreeBuilder rendererTreeBuilder,
            ITableDataSet tableDataSet,
            ISpecialColumnFragmentsCollection specialColumnFragmentsCollection,
            FlexGridContext flexGridContext)
        {
            if (imutableGridRendererContext is null)
            {
                throw new ArgumentNullException(nameof(imutableGridRendererContext));
            }

            RendererTreeBuilder = rendererTreeBuilder ?? throw new ArgumentNullException(nameof(RendererTreeBuilder));
            TableDataSet        = tableDataSet ?? throw new ArgumentNullException(nameof(tableDataSet));
            FlexGridContext     = flexGridContext ?? throw new ArgumentNullException(nameof(flexGridContext));

            GridConfiguration            = imutableGridRendererContext.GridConfiguration;
            GridItemProperties           = imutableGridRendererContext.GridItemProperties;
            GridItemCollectionProperties = imutableGridRendererContext.GridEntityConfiguration.ClrTypeCollectionProperties;
            CssClasses            = imutableGridRendererContext.CssClasses;
            PropertyValueAccessor = imutableGridRendererContext.GetPropertyValueAccessor;

            gridEntityConfiguration = imutableGridRendererContext.GridEntityConfiguration;
            valueFormatters         = imutableGridRendererContext.ValueFormatters;
            columnRendererFragments = specialColumnFragmentsCollection
                                      .Merge(gridEntityConfiguration, imutableGridRendererContext.ColumnRendererFragments);
            columnEditRendererBuilders = specialColumnFragmentsCollection
                                         .Merge(gridEntityConfiguration, imutableGridRendererContext.ColumnEditRendererBuilders);

            firstColumnName = GridItemProperties.First().Name;
            lastColumnName  = GridItemProperties.Last().Name;
            NumberOfColumns = GridItemProperties.Count +
                              (imutableGridRendererContext.InlineEditItemIsAllowed() || imutableGridRendererContext.CreateItemIsAllowed() ? 1 : 0) +
                              (GridConfiguration.IsMasterTable ? 1 : 0);
        }
        public GridRendererContext(
            ImutableGridRendererContext imutableGridRendererContext,
            IRendererTreeBuilder rendererTreeBuilder,
            ITableDataSet tableDataSet)
        {
            if (imutableGridRendererContext is null)
            {
                throw new ArgumentNullException(nameof(imutableGridRendererContext));
            }

            GridConfiguration            = imutableGridRendererContext.GridConfiguration;
            GridItemProperties           = imutableGridRendererContext.GridItemProperties;
            GridItemCollectionProperties = imutableGridRendererContext.GridEntityConfiguration.ClrTypeCollectionProperties;
            CssClasses                  = imutableGridRendererContext.CssClasses;
            PropertyValueAccessor       = imutableGridRendererContext.GetPropertyValueAccessor;
            RendererTreeBuilder         = rendererTreeBuilder ?? throw new ArgumentNullException(nameof(RendererTreeBuilder));
            RequestRerenderNotification = imutableGridRendererContext.RequestRerenderNotification;
            TableDataSet                = tableDataSet ?? throw new ArgumentNullException(nameof(tableDataSet));

            TableDataSet.GroupingOptions.SetConfiguration(GridConfiguration?.GroupingOptions);
            TableDataSet.GroupingOptions.GroupableProperties = this.GridItemProperties.ToList();

            this.gridEntityConfiguration = imutableGridRendererContext.GridEntityConfiguration;
            this.valueFormatters         = imutableGridRendererContext.ValueFormatters;
            this.specialColumnValues     = imutableGridRendererContext.SpecialColumnValues;
            this.firstColumnName         = GridItemProperties.First().Name;
            this.lastColumnName          = GridItemProperties.Last().Name;
        }
Exemple #5
0
        public static string PageInfoText(this ITableDataSet tableDataSet)
        {
            var from = tableDataSet.PageableOptions.CurrentPage * tableDataSet.PageableOptions.PageSize + 1;
            var to   = from + tableDataSet.PageableOptions.PageSize - 1;

            return($"{from} - {Math.Min(to, tableDataSet.PageableOptions.TotalItemsCount)}");
        }
        CreateContexts(ITableDataSet tableDataSet, RenderTreeBuilder renderTreeBuilder)
        {
            var imutableRendererContext = GetImutableGridRendererContext(tableDataSet.UnderlyingTypeOfItem());

            return(new GridRendererContext(imutableRendererContext, new BlazorRendererTreeBuilder(renderTreeBuilder), tableDataSet),
                   imutableRendererContext.PermissionContext);
        }
        private ITableDataSet GetTableDataSet()
        {
            var tableDataSet = DataAdapter?.GetTableDataSet(conf =>
            {
                conf.LazyLoadingOptions       = LazyLoadingOptions;
                conf.PageableOptions.PageSize = PageSize;
                conf.GridViewEvents           = new GridViewEvents
                {
                    SaveOperationFinished   = this.SaveOperationFinished,
                    DeleteOperationFinished = this.DeleteOperationFinished,
                    NewItemCreated          = this.NewItemCreated,
                    OnItemClicked           = this.OnItemClicked
                };
            });

            if (tableDataSet is null)
            {
                return(new TableDataSet <EmptyDataSetItem>(Enumerable.Empty <EmptyDataSetItem>().AsQueryable()));
            }

            tableDataSet = MasterDetailTableDataSetFactory.ConvertToMasterTableIfIsRequired(tableDataSet);


            return(tableDataSet);
        }
 public static async Task GoToFirstPage(this ITableDataSet tableDataSet)
 {
     if (!tableDataSet.PageableOptions.IsFirstPage)
     {
         await tableDataSet.GoToPage(0);
     }
 }
Exemple #9
0
        protected override Task OnInitAsync()
        {
            dataAdapterWasEmptyInOnInit = DataAdapter == null;

            tableDataSet = GetTableDataSet() ?? new TableDataSet <EmptyDataSetItem>(Enumerable.Empty <EmptyDataSetItem>().AsQueryable());

            return(tableDataSet.GoToPage(0));
        }
Exemple #10
0
        public static Task GoToFirstPage(this ITableDataSet tableDataSet)
        {
            if (!tableDataSet.PageableOptions.IsFirstPage)
            {
                tableDataSet.GoToPage(0);
            }

            return(Task.FromResult(0));
        }
        public static Task GoToNextPage(this ITableDataSet tableDataSet)
        {
            if (!tableDataSet.PageableOptions.IsLastPage)
            {
                return(tableDataSet.GoToPage(tableDataSet.PageableOptions.CurrentPage + 1));
            }

            return(Task.FromResult(0));
        }
Exemple #12
0
        public static Task GoToLastPage(this ITableDataSet tableDataSet)
        {
            if (!tableDataSet.PageableOptions.IsLastPage)
            {
                tableDataSet.GoToPage(tableDataSet.PageableOptions.PagesCount - 1);
            }

            return(Task.FromResult(0));
        }
        public static Task GoToPreviousPage(this ITableDataSet tableDataSet)
        {
            if (!tableDataSet.PageableOptions.IsFirstPage)
            {
                return(tableDataSet.GoToPage(tableDataSet.PageableOptions.CurrentPage - 1));
            }

            return(Task.FromResult(0));
        }
Exemple #14
0
        protected override Task OnParametersSetAsync()
        {
            if (dataAdapterWasEmptyInOnInit && DataAdapter != null)
            {
                tableDataSet = GetTableDataSet();
                return(tableDataSet.GoToPage(0));
            }

            return(Task.FromResult(0));
        }
        protected override async Task OnParametersSetAsync()
        {
            if (dataAdapterWasEmptyInOnInit && DataAdapter != null)
            {
                ConventionsSet.ApplyConventions(DataAdapter.UnderlyingTypeOfItem);
                tableDataSet = GetTableDataSet();

                await tableDataSet.GoToPage(0);
            }
        }
        public static void ToggleGroupRow <TItem>(this ITableDataSet tableDataSet, object groupItemKey)
        {
            var keyEqualityComparer = new GroupingKeyEqualityComparer();
            var groupItemToToggle   = tableDataSet.GroupedItems.FirstOrDefault(item => keyEqualityComparer.Equals(item.Key, groupItemKey));

            groupItemToToggle.IsCollapsed = !groupItemToToggle.IsCollapsed;

            tableDataSet.GroupedItems = tableDataSet.GroupedItems.Select(item => !keyEqualityComparer.Equals(((GroupItem <TItem>)item).Key, groupItemKey)
                                                                ? item
                                                                : groupItemToToggle);
        }
        public GridRendererContext CreateRendererContext(ITableDataSet tableDataSet, RenderTreeBuilder renderTreeBuilder)
        {
            var itemType        = tableDataSet.GetType().GenericTypeArguments[0];
            var rendererContext = new GridRendererContext(
                GetImutableGridRendererContext(itemType),
                renderTreeBuilder,
                tableDataSet
                );

            return(rendererContext);
        }
        protected override Task OnParametersSetAsync()
        {
            if (dataAdapterWasEmptyInOnInit && DataAdapter != null)
            {
                ConventionsSet.ApplyConventions(DataAdapter.UnderlyingTypeOfItem);
                tableDataSet = GetTableDataSet();
                return(tableDataSet.GoToPage(0));
            }

            return(Task.FromResult(0));
        }
 public MasterDetailTableDataSet(
     ITableDataSet tableDataSet,
     IGridConfigurationProvider gridConfigurationProvider,
     ITableDataAdapterProvider tableDataAdapterProvider)
 {
     this.tableDataSet             = tableDataSet ?? throw new ArgumentNullException(nameof(tableDataSet));
     this.tableDataAdapterProvider = tableDataAdapterProvider ?? throw new ArgumentNullException(nameof(tableDataAdapterProvider));
     this.tableDataAdapters        = new HashSet <ITableDataAdapter>();
     this.selectedDataAdapters     = new Dictionary <object, ITableDataAdapter>();
     this.gridConfiguration        = gridConfigurationProvider?.FindGridEntityConfigurationByType(typeof(TItem)) ?? throw new ArgumentNullException(nameof(gridConfigurationProvider));
 }
        protected override async Task OnInitAsync()
        {
            dataAdapterWasEmptyInOnInit = DataAdapter == null;
            if (!dataAdapterWasEmptyInOnInit)
            {
                ConventionsSet.ApplyConventions(DataAdapter.UnderlyingTypeOfItem);
            }

            tableDataSet = GetTableDataSet();

            await tableDataSet.GoToPage(0);
        }
Exemple #21
0
        private ITableDataSet GetTableDataSet()
        {
            var tableDataSet = DataAdapter?.GetTableDataSet(conf =>
            {
                conf.LazyLoadingOptions.DataUri = LazyLoadingOptions.DataUri;
                conf.PageableOptions.PageSize   = PageSize;
            });

            if (tableDataSet is null)
            {
                return(new TableDataSet <EmptyDataSetItem>(Enumerable.Empty <EmptyDataSetItem>().AsQueryable()));
            }

            tableDataSet = MasterDetailTableDataSetFactory.ConvertToMasterTableIfIsRequired(tableDataSet);

            return(tableDataSet);
        }
        public ITableDataSet ConvertToMasterTableIfIsRequired(ITableDataSet tableDataSet)
        {
            if (tableDataSet is IMasterTableDataSet masterTableDataSet)
            {
                return(masterTableDataSet);
            }

            var entityConfiguration = gridConfigurationProvider.GetGridConfigurationByType(tableDataSet.UnderlyingTypeOfItem());

            if (!entityConfiguration.IsMasterTable)
            {
                return(tableDataSet);
            }

            var masterDetailTableDataSetType = typeof(MasterDetailTableDataSet <>).MakeGenericType(tableDataSet.UnderlyingTypeOfItem());
            var masterDetailTableDataSet     = Activator.CreateInstance(masterDetailTableDataSetType,
                                                                        new object[] { tableDataSet, gridConfigurationProvider, tableDataAdapterProvider }) as IMasterTableDataSet;

            return(masterDetailTableDataSet);
        }
        public GridRendererContext(
            ImutableGridRendererContext imutableGridRendererContext,
            RenderTreeBuilder renderTreeBuilder,
            ITableDataSet tableDataSet)
        {
            if (imutableGridRendererContext is null)
            {
                throw new ArgumentNullException(nameof(imutableGridRendererContext));
            }

            GridItemProperties           = imutableGridRendererContext.GridItemProperties;
            CssClasses                   = imutableGridRendererContext.CssClasses;
            GridConfiguration            = new GridAnotations(imutableGridRendererContext.GridEntityConfiguration);
            TableDataSet                 = tableDataSet ?? throw new ArgumentNullException(nameof(tableDataSet));
            this.gridEntityConfiguration = imutableGridRendererContext.GridEntityConfiguration;
            this.propertyValueAccessor   = imutableGridRendererContext.GetPropertyValueAccessor;
            this.valueFormatters         = imutableGridRendererContext.ValueFormatters;
            this.renderTreeBuilder       = renderTreeBuilder ?? throw new ArgumentNullException(nameof(renderTreeBuilder));
            this.firstColumnName         = GridItemProperties.First().Name;
        }
        public static int DetailGridViewPageSize(this IMasterDetailRelationship masterDetailRelationship, ITableDataSet masterTableDataSet)
        {
            if (masterTableDataSet == null)
            {
                throw new ArgumentNullException(nameof(masterTableDataSet));
            }

            var pageSizeAnnotationValue = masterDetailRelationship[GridViewAnnotationNames.DetailTabPageSize];

            if (pageSizeAnnotationValue is NullAnotationValue)
            {
                return(masterTableDataSet.PageableOptions.PageSize);
            }

            return((int)pageSizeAnnotationValue);
        }
Exemple #25
0
 public static bool HasGroupedItems(this ITableDataSet tableDataSet)
 => tableDataSet.Items != null && tableDataSet.Items.Count > 0;
Exemple #26
0
 public GridRendererContext CreateRendererContext(ITableDataSet tableDataSet, RenderTreeBuilder renderTreeBuilder)
 => new GridRendererContext(
     GetImutableGridRendererContext(tableDataSet.UnderlyingTypeOfItem()),
     renderTreeBuilder,
     tableDataSet);
        public (ImutableGridRendererContext ImutableRendererContext, PermissionContext PermissionContext) CreateContexts(ITableDataSet tableDataSet)
        {
            var imutableRendererContext = GetImutableGridRendererContext(tableDataSet.UnderlyingTypeOfItem());

            return(imutableRendererContext, imutableRendererContext.PermissionContext);
        }
 public static bool IsItemEdited(this ITableDataSet tableDataSet, object item)
 => tableDataSet.RowEditOptions.ItemInEditMode == item;
 public static Type UnderlyingTypeOfItem(this ITableDataSet tableDataSet)
 => tableDataSet.GetType().GenericTypeArguments[0];
 public static bool HasItems(this ITableDataSet tableDataSet)
 => !(tableDataSet.Items == null || tableDataSet.Items.Count <= 0);