vikramlearning / blazorbootstrap

An Enterprise-class Blazor Bootstrap Component library built on the Blazor and Bootstrap CSS frameworks.
https://docs.blazorbootstrap.com/
Apache License 2.0
782 stars 41 forks source link

Grid - with AllowPaging=true #884

Open mrcorale opened 2 months ago

mrcorale commented 2 months ago

Hello, I am getting an error when adding AllowPaging="true" to the grid. Below you will see the error:

blazor.server.js:1 [2024-09-19T10:31:47.510Z] Error: System.InvalidOperationException: Microsoft.AspNetCore.Components.Forms.InputSelect1[System.Int32] requires a cascading parameter of type EditContext. For example, you can use Microsoft.AspNetCore.Components.Forms.InputSelect1[[System.Int32, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]] inside an EditForm. at Microsoft.AspNetCore.Components.Forms.InputBase`1.SetParametersAsync(ParameterView parameters) at Microsoft.AspNetCore.Components.Rendering.ComponentState.SupplyCombinedParameters(ParameterView directAndCascadingParameters)

<Grid TItem="Employee1" AllowFiltering="true" AllowPaging="true" AllowSorting="true" Class="table table-hover" DataProvider="EmployeesDataProvider" FiltersRowCssClass="bg-dark text-white bg-opacity-25 border-bottom-0" FiltersTranslationProvider="GridFiltersTranslationProvider" HeaderRowCssClass="bg-dark text-white border-bottom-0" PageSize="10" PageSizeSelectorVisible="true" PageSizeSelectorItems="@(new int[] { 5,10,20 })" PaginationItemsTextFormat="{0} - {1} van {2} artikelen" ItemsPerPageText="Artikelen per pagina" Responsive="true">

<GridColumns>
    <GridColumn TItem="Employee1" HeaderText="Id" PropertyName="Id" SortKeySelector="item => item.Id">
        @context.Id
    </GridColumn>
    <GridColumn TItem="Employee1" HeaderText="Employee Name" PropertyName="Name" SortKeySelector="item => item.Name">
        @context.Name
    </GridColumn>
    <GridColumn TItem="Employee1" HeaderText="Designation" PropertyName="Designation" SortKeySelector="item => item.Designation">
        @context.Designation
    </GridColumn>
    <GridColumn TItem="Employee1" HeaderText="DOJ" PropertyName="DOJ" SortKeySelector="item => item.DOJ">
        @context.DOJ
    </GridColumn>
    <GridColumn TItem="Employee1" HeaderText="Active" PropertyName="IsActive" SortKeySelector="item => item.IsActive">
        @context.IsActive
    </GridColumn>
</GridColumns>

gvreddy04 commented 2 months ago

@mrcorale Thank you for using BlazorBootstrap. It appears you were missing something. Please share a sample GitHub repo with minimal steps to reproduce the issue.

Demos - Grid Paging: https://demos.blazorbootstrap.com/grid/paging

NOTE: Do not include any personal/company information in the sample.

gvreddy04 commented 2 months ago

@mrcorale Assuming your current page has an InputSelect, that is creating the problem.

mrcorale commented 2 months ago

https://github.com/mrcorale/Blazor-Bootstrap.git

Here are the two issues summarized:

1.InputSelect 2.The Tooltip content doesn't update when the InputSelect value changes. Need to refresh the Tooltip when Name changes,

mrcorale commented 1 month ago

Hello, you haven't answered why it gives me an error when I add AllowPaging="true" in the grid!

mrcorale commented 2 weeks ago

The error disappears if use Grid inside CascadingValue Value="_editContext":

CascadingValue Value="_editContext" <Grid TItem="Employee1" AllowFiltering="true" AllowPaging="true" AllowSorting="true" Class="table table-hover" DataProvider="EmployeesDataProvider" FiltersRowCssClass="bg-dark text-white bg-opacity-25 border-bottom-0" FiltersTranslationProvider="GridFiltersTranslationProvider" HeaderRowCssClass="bg-dark text-white border-bottom-0" PageSize="10" PageSizeSelectorVisible="true" PageSizeSelectorItems="@(new int[] { 5,10,20 })" PaginationItemsTextFormat="{0} - {1} van {2} artikelen" ItemsPerPageText="Artikelen per pagina" Responsive="true">

    <GridColumns>
        <GridColumn TItem="Employee1" HeaderText="Id" PropertyName="Id" SortKeySelector="item => item.Id">
            @context.Id
        </GridColumn>
        <GridColumn TItem="Employee1" HeaderText="Employee Name" PropertyName="Name" SortKeySelector="item => item.Name">
            @context.Name
        </GridColumn>
        <GridColumn TItem="Employee1" HeaderText="Designation" PropertyName="Designation" SortKeySelector="item => item.Designation">
            @context.Designation
        </GridColumn>
        <GridColumn TItem="Employee1" HeaderText="DOJ" PropertyName="DOJ" SortKeySelector="item => item.DOJ">
            @context.DOJ
        </GridColumn>
        <GridColumn TItem="Employee1" HeaderText="Active" PropertyName="IsActive" SortKeySelector="item => item.IsActive">
            @context.IsActive
        </GridColumn>
    </GridColumns>

</Grid>

/CascadingValue