We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Filter by column RoleName does not work when inheriting from SfGridView

<CustomGridAddEditDel @ref="customGrid" ID="testCust" TValue="UserReturnView" AllowSorting="true" AllowFiltering="true" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Edit", "Delete" })">

    <SfDataManager AdaptorInstance="typeof(UserAdmAdaptor)" Adaptor="Adaptors.CustomAdaptor"></SfDataManager>

    <GridFilterSettings Mode="FilterBarMode.Immediate" ShowFilterBarStatus="false" />

    <GridPageSettings PageSizes="true"></GridPageSettings>


    <GridEvents OnActionComplete="ActionCompleteCallback" DataBound="DataHandler" OnActionFailure="FailureCallback" OnActionBegin="ActionBegin" TValue="UserReturnView"></GridEvents>


    <GridEditSettings AllowEditing="true" AllowDeleting="true" AllowAdding="true" Mode="@EditMode.Dialog">


        <Validator>

            <DataAnnotationsValidator></DataAnnotationsValidator>

        </Validator>

        <HeaderTemplate>

            @{

                var user = context as UserReturnView;

                if (user.UserId > 0)

                {

                    <span>Edit</span>

                }

                else

                {

                    <span>Add</span>

                }

            }

        </HeaderTemplate>


        <Template>

            @{


                var user = context as UserReturnView;

                <div>

                    <div class="row">

                        <div class="col-md-6">

                            <label class="form-label">First name</label>

                            <SfTextBox ID="FirstName" @bind-Value="@(user.FirstName)" Placeholder="First name"></SfTextBox>

                            <ValidationMessage For="(()=>user.FirstName)" />

                        </div>

                        <div class="col-md-6">

                            <label class="form-label">Last name</label>

                            <SfTextBox ID="LastName" Placeholder="Last name" @bind-Value="@(user.LastName)"></SfTextBox>

                            <ValidationMessage For="(()=>user.LastName)" />

                        </div>

                    </div>


                    <div class="row">

                        <div class="col-md-6">

                            <label class="form-label">Role</label>

                            <SfDropDownList ID="EditRole" TValue="int" @bind-Value="@(user.RoleId)" TItem="Role" Placeholder="Select a role" ShowClearButton="true">

                                <SfDataManager AdaptorInstance="typeof(UserRoleAdmAdapter)" Adaptor="Adaptors.CustomAdaptor"></SfDataManager>


                                <DropDownListFieldSettings Text="@nameof(Role.Name)" Value="@nameof(Role.RoleId)" />

                            </SfDropDownList>

                            <ValidationMessage For="(()=>user.RoleId)" />

                        </div>

                        <div class="col-md-6">

                            <label class="form-label">Email Address</label>

                            <SfTextBox ID="Email address" @bind-Value="@(user.EmailAddress)" Type="InputType.Email" Placeholder="Email address"></SfTextBox>

                            <ValidationMessage For="(()=>user.EmailAddress)" />

                        </div>

                    </div>


                    <div class="row">

                        <div class="col-md-6">

                            <label class="form-label">Password</label>

                            <SfTextBox ID="Password" @bind-Value="@user.Password" Enabled="IsAdd" Type="InputType.Password" Placeholder="Password"></SfTextBox>

                            <ValidationMessage For="(()=>user.Password)" />

                        </div>

                        <div class="col-md-6">

                            <label class="form-label">Password comfirm</label>

                            <SfTextBox ID="Password confirm" @bind-Value="@user.PasswordConfirm" Type="InputType.Password" Enabled="IsAdd" Placeholder="Password confirm"></SfTextBox>

                            <ValidationMessage For="(()=>user.PasswordConfirm)" />

                        </div>

                    </div>


                </div>

            }

        </Template>

    </GridEditSettings>

    <GridColumns>

        <GridColumn Field=@nameof(UserReturnView.UserId) IsPrimaryKey="true" IsIdentity="true" Visible="false" />

        <GridColumn Field=@nameof(UserReturnView.FirstName) HeaderText="First Name" Width="150"></GridColumn>

        <GridColumn Field=@nameof(UserReturnView.LastName) HeaderText="Last Name" Width="150"></GridColumn>

        <GridColumn Field=@nameof(UserReturnView.RoleName) HeaderText="Role Name" Width="150">

            <FilterTemplate>

                <SfDropDownList ID="filterRole2" TValue="int" TItem="Role" Placeholder="Select a role" ShowClearButton="true">

                    <SfDataManager AdaptorInstance="typeof(UserRoleAdmAdapter)" Adaptor="Adaptors.CustomAdaptor"></SfDataManager>

                    <DropDownListFieldSettings Text="@nameof(Role.Name)" Value="@nameof(Role.RoleId)" />

                    <DropDownListEvents TItem="Role" TValue="int" ValueChange="@CustomGridValueChangeHandler" />

                </SfDropDownList>

            </FilterTemplate>

        </GridColumn>

        <GridColumn Field=@nameof(UserReturnView.EmailAddress) HeaderText="Email address" Width="150"></GridColumn>

    </GridColumns>


</CustomGridAddEditDel>


10 Replies 1 reply marked as answer

KA kavit November 2, 2022 08:18 PM UTC

CustomGridAddEditDel


@typeparam TValue

@inherits SfGrid<TValue>

<RemoveDialog @ref="@removeDialog" TypeGrid="TValue" Grid="@this"></RemoveDialog>

<SfGrid TValue="TValue" ID="gridCust" AllowSorting="true" AllowFiltering="true" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Edit", "Delete" })" @attributes="props">


    @*<GridPageSettings PageCount="@PAGE_COUNT" PageSize="@DEFAULT_PAGE_SIZE" PageSizes="@PageSizes"></GridPageSettings>

    <GridFilterSettings Mode="FilterBarMode.Immediate" ShowFilterBarStatus="false" />*@

    @ChildContent

</SfGrid>






KA kavit November 2, 2022 08:21 PM UTC

   at Syncfusion.Blazor.Grids.Internal.Filter`1.<FilterByColumn>d__86.MoveNext()

   at Syncfusion.Blazor.Grids.SfGrid`1.<FilterByColumnAsync>d__1061.MoveNext()

   at Northwind.Interface.Server.Pages.SfUsersAdmModel.<CustomGridValueChangeHandler>d__9.MoveNext() in F:\PresentationProjectNorthwind\Northwind.Interface.Server\Pages\SfUsersAdmModel.cs:line 25



SP Sarveswaran Palani Syncfusion Team November 3, 2022 05:27 PM UTC

Hi Kavit,


Greetings from Syncfusion support.


Based on your update, we suspect that you’re facing issue in filtering records in column. So, we created simple level custom component sample for filtering. But we’re unable to face any issue while filtering. So, Before proceeding further Kindly share the following details to us.


  1. Share the video demo or screenshot of an issue
  2. What kind of issue you are facing?
  3. In which operation, this issue was occurred?
  4. If possible, kindly share the issue reproducible sample to us
  5. Or reproduce the reported issue in the provided sample


Above request details will be very helpful for us to validate the reported query at our end and provide solution as easy as possible.


Regards,

Sarveswaran PK


Attachment: SfCustomGrid_2bc14baa.zip


KA kavit November 7, 2022 12:16 PM UTC

made an error example. In the first column of the lower grid there is a drop down list, when you select, you get an error.


Attachment: SfCustomGrid_7676e4fa.zip


KA kavit November 9, 2022 01:02 PM UTC

can you help with a solution?



SP Sarveswaran Palani Syncfusion Team November 15, 2022 03:39 AM UTC

Hi Kavit,


Sorry for the delay,


Based on your query, we suspect that you want to filter records using dropdown on Custom component sample. Kindly refer the shared code snippet and attached sample modified sample for your reference.


CustomGrid.razor.cs

public partial class CustomGrid<TValue> : SfGrid<TValue>

{

    SfGrid<TValue> Grid1;

 

    public async Task CustomFilter(string val)

    {

        await Grid1.FilterByColumnAsync("CustomerID", "equal", val);

    }

}

 

Index.razor

 

private async void ValueChangeHandler(ChangeEventArgs<string, Customer> obj)

{    

  await grid.CustomFilter(obj.Value);

}


Regards,

Sarveswaran PK


Attachment: SfCustomGridModified_9c1e29a.zip

Marked as answer

KA kavit November 15, 2022 11:53 AM UTC

Thanks for the solution.



KA kavit November 15, 2022 01:32 PM UTC

If I Add 

 <GridEditSettings>

 </GridEditSettings>

to Custom grid, not working even add, edit, del in customAdapter class.



KA kavit November 15, 2022 09:46 PM UTC

Understood. It was necessary to specify in the id of the menu elements, the id of the table from html.



SP Sarveswaran Palani Syncfusion Team November 18, 2022 03:29 AM UTC

Hi Kavit,

We suspect that your issue has been resolved by yourself. Please get back to us if you need any further assistance.

Regards,
Sarvesh


Loader.
Live Chat Icon For mobile
Up arrow icon