Grid search does not work if the grid contains GridForeignColumn
Searching via the search field in the grid toolbar does not work if the grid contains GridForeignColumn.
If there are GridForeignColumns in the grid, the search will not find any records and the grid will print "no records to view". No error is printed either.
If I remove the GridForeignColumns from the grid, the search works normally and the corresponding records are displayed.
The page code is here
@page "/admin/zamestnanci2"
@attribute [Authorize(Roles = "AppAdmin")]
@using Syncfusion.Blazor.Grids
@using TextAlign = Syncfusion.Blazor.Grids.TextAlign
@using FilterType = Syncfusion.Blazor.Grids.FilterType
@inject DataService _dataService
<main role="main" class="container-fluid" style="z-index:999">
<SfGrid ID="GridZamestnanci3" @ref="_grid"
TValue="ZamestnanecDto" RowHeight="25"DataSource="@_vm" ShowColumnChooser="true" Toolbar="@_toolbaritems">
<GridPageSettings PageSize="@_pagesize" PageSizes="@StaticConfig.GridPageSizes"></GridPageSettings>
<GridSortSettings>
<GridSortColumns>
<GridSortColumn Field="@nameof(ZamestnanecDto.Prijmeni)" Direction="SortDirection.Ascending"></GridSortColumn>
</GridSortColumns>
</GridSortSettings>
<GridFilterSettings Type="FilterType.Excel"></GridFilterSettings>
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true"></GridEditSettings>
<GridColumns>
<GridColumn Field="@nameof(ZamestnanecDto.IdZamestnance)" HeaderText="ID" AllowEditing="false"
IsPrimaryKey="true" AllowAdding="false" Visible="false" />
<GridColumn Field="@nameof(ZamestnanecDto.Jmeno)" HeaderText="Jméno"
ValidationRules="@(new ValidationRules { Required = true })" />
<GridColumn Field="@nameof(ZamestnanecDto.Prijmeni)" HeaderText="Příjmení"
ValidationRules="@(new ValidationRules { Required = true })" />
<GridColumn Field="@nameof(ZamestnanecDto.Titul)" HeaderText="Titul" Visible="false" />
<GridColumn Field="@nameof(ZamestnanecDto.OsobniCislo)" HeaderText="Os.čís." Visible="false" />
<GridColumn Field="@nameof(ZamestnanecDto.DomenoveJmeno)" HeaderText="AD" />
<GridColumn Field="@nameof(ZamestnanecDto.Email)" HeaderText="Email" />
<GridColumn Field="@nameof(ZamestnanecDto.Telefon)" HeaderText="Telefon" />
<GridForeignColumn Field=@nameof(ZamestnanecVM.IdStrediska) HeaderText="Středisko"
ForeignKeyValue="NazevStrediska" ForeignDataSource="@ListStrediska"
Width="150" AllowSearching="false" />
<GridForeignColumn Field=@nameof(ZamestnanecVM.IdVratnice) HeaderText="Vrátnice"
ForeignKeyValue="NazevVratnice" ForeignDataSource="@ListVratnice"
Width="150" AllowSearching="false" />
<GridColumn Field="@nameof(ZamestnanecDto.IdCardNumber)" HeaderText="IdCardNumber" Visible="false" />
<GridColumn Field="@nameof(ZamestnanecDto.Poznamka)" HeaderText="Poznámka" Visible="false" />
<GridColumn Field="@nameof(ZamestnanecDto.RoleTxt)" HeaderText="Role" Visible="true" AllowAdding="false" AllowEditing="false" />
<GridColumn Field=@nameof(ZamestnanecVM.Neaktivni) HeaderText="Neaktivní" EditType="EditType.BooleanEdit" TextAlign="TextAlign.Center">
<Template>
@{
if (context is ZamestnanecVM { Neaktivni: true } d)
{
<i class="pe-1 fa-light fa-circle-xmark text-danger"></i>
}
}
</Template>
</GridColumn>
</GridColumns>
</SfGrid>
</main>
@code {
List<ZamestnanecDto> _vm = new();
private readonly List<Object> _toolbaritems = new() { "Search"};
SfGrid<ZamestnanecDto> _grid;
public List<VratniceVM> ListVratnice { get; set; }
public List<StrediskoVM> ListStrediska { get; set; }
private int _pagesize { get; set; } = StaticConfig.GridDefaultPagSize;
protected override async Task OnInitializedAsync()
{
ListStrediska = await _dataService.GetStrediskaAsync();
ListVratnice = await _dataService.GetVratniceAsync();
_vm = await _dataService.GetLidiDtoAsync();
await base.OnInitializedAsync();
}
}
Is the error somewhere with me or in the grid component ?
Hi penodc,
Greeting from Syncfusion support.
Query:" If there are GridForeignColumns in the grid, the search will
not find any records and the grid will print "no records to view". No
error is printed either."
After reviewing your shared code snippet, we have identified that the issue occurred due to you have set the AllowSearching="false" . We have modified your shared code snippet . Kindly refer the below code snippet to resolve your issues.
|
<GridForeignColumn Field=@nameof(ZamestnanecVM.IdStrediska) HeaderText="Středisko" ForeignKeyValue="NazevStrediska" ForeignDataSource="@ListStrediska" Width="150" AllowSearching="true" /> <GridForeignColumn Field=@nameof(ZamestnanecVM.IdVratnice) HeaderText="Vrátnice" ForeignKeyValue="NazevVratnice" ForeignDataSource="@ListVratnice" Width="150" AllowSearching="true" /> |
Please get back to us if you have further queries.
Hi.
There seems to be a misunderstanding of the problem here.
I don't primarily need to search in ForeignColumns. (bonus for me if it works).
Searching through stadard other columns in the grid (FirstName,LastName,Email ...) is enough for me, but even that doesn't work if any column of type ForeignColumn is present in the grid.
Setting AllowSearching="false" on ForeignColumns was my attempt to solve the problem but unfortunately it didn't work.
Thank you for any suggestion for a solution.
Hi Penodc,
We tried to reproduce the reported issue at our end while preparing the sample
based on your shared code snippet. But we are not able reproduce the reported
issue at our end. We have attached the simple sample for your reference. Kindly
refer the attached sample file to resolve your issues.
If the issue still persists, Kindly share us the below requested details for
further validation.
- Share us the issue reproducible video demo.
- If possible, Kindly modify the attached sample as per your requirement.
- If possible, kindly share us a simple issue reproduceable sample .
Above requested details will be very helpful in validating the reported query at our end and provide solution as early as possible.
Attachment: BlazorApp1_7de4ec98.zip
- 3 Replies
- 2 Participants
-
PE penodc
- Sep 19, 2023 09:29 AM UTC
- Sep 22, 2023 06:56 AM UTC