Hi, I am using DataGrid control with OData V4 adaptor and im encountering an issue where filtering on boolean values to remote data fails. Im using version 27.2.4 but i have tried multiple version from 27.2.X series.
Here is my base grid im using:
<SfGrid @ref="@DataGrid" TValue="TModel" AllowPaging="true" AllowFiltering="true" ID="@GridID" EnablePersistence="true"
AllowReordering="true" AllowResizing="true" AllowGrouping="true" AllowExcelExport="true"
AllowPdfExport="true" AllowSelection="true" AllowSorting="true"
ShowColumnChooser="true" Toolbar="@Toolbar">
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="Syncfusion.Blazor.Grids.EditMode.Normal"></GridEditSettings>
<GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Excel">
<GridFilterColumns>
<GridFilterColumn Field="IsDeleted" MatchCase="false" Operator="Operator.Equal" Predicate="and" Value="@false"></GridFilterColumn>
</GridFilterColumns>
</GridFilterSettings>
<GridPageSettings PageSize="20" PageSizes="new int[]{10,20,50,100}"></GridPageSettings>
<GridSelectionSettings Type="Syncfusion.Blazor.Grids.SelectionType.Single" PersistSelection="true" CheckboxMode="CheckboxSelectionType.ResetOnRowClick"></GridSelectionSettings>
<SfDataManager Url="@Url" Adaptor="Adaptors.ODataV4Adaptor" AdaptorInstance="@typeof(ODataV4Adaptor)"></SfDataManager>
<GridEvents TValue="TModel" OnLoad="OnGridLoad" OnActionBegin="ActionBegin" OnActionComplete="ActionComplete" OnToolbarClick="ToolbarClickHandler"></GridEvents>
<GridColumns>
@ChildContent
</GridColumns>
</SfGrid>
Im using data model called Partner, which has a boolean property called IsDeleted.
In my developer console i can see the generated query treats this
IsDeleted
property as if it were a string.
Here is the full URL that it generates:
https://localhost:7048/odata/Partner?$count=true&$filter=(tolower(IsDeleted)%20eq%20%27false%27)&$skip=0&$top=20
At the same time i got this response message:
"message": "The query specified in the URI is not valid. No function signature for the function with name 'tolower' matches the specified arguments. The function signatures considered are: tolower(Edm.String Nullable=true)."
Before upgrading to version 27.X, this exact setup worked without any issues on version 21.X. I found a similar issue, which was posted in 2021, in that case a new version solved the problem. I believe its a similar case, here is that forum link:
https://www.syncfusion.com/forums/162724/sfgrid-issues-filtering-on-boolean-values-when-using-odata-v4-adaptor
Im looking forword to your response and i would appreciate any suggestion if i have done something wrong. Thank you.
Hi Szabolcs,
Greetings from Syncfusion.
We have prepared a simple sample as per your shared reference code but we could not able to replicate the reported issue at our end while using latest version.
Kindly check the below sample and output for your reference.
|
<SfGrid TValue="OrgUnit" AllowPaging="true" AllowFiltering=true AllowGrouping=true Toolbar="@ToolbarItems"> <SfDataManager Url="odata/OrgUnits" Adaptor="Adaptors.ODataV4Adaptor" Key="Id" /> <GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Excel">
<GridFilterColumns>
<GridFilterColumn Field="HasChild" MatchCase="false" Operator="Operator.Equal" Predicate="and" Value="@false"></GridFilterColumn>
</GridFilterColumns>
</GridFilterSettings> <GridEvents TValue="OrgUnit" FilterDialogOpened="FilterDialogOpeneHandler" OnActionFailure="@ActionFailure"></GridEvents> </SfGrid> |
|
|
Kindly get back to us if we misunderstood your query or if you have further queries.
Regards,
Monisha
Thank you for your response. I downloaded and tested your example, and it worked perfectly. However, the issue persisted in my project. To make debugging easier, I made a few modifications and added the data type directly to the TValue property of the data grid:
<SfGrid @ref="@DataGrid" TValue="Partner" AllowPaging="true" AllowFiltering="true" EnablePersistence="true" ID="partnerID"
ShowColumnChooser="true"
Toolbar="@ToolbarItems">
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="Syncfusion.Blazor.Grids.EditMode.Normal"></GridEditSettings>
<GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Excel">
<GridFilterColumns>
<GridFilterColumn Field="IsDeleted" MatchCase="false" Operator="Operator.Equal" Predicate="and" Value="@false"></GridFilterColumn>
</GridFilterColumns>
</GridFilterSettings>
<GridPageSettings PageSize="20" PageSizes="new int[]{10,20,50,100}"></GridPageSettings>
<GridSelectionSettings Type="Syncfusion.Blazor.Grids.SelectionType.Single" PersistSelection="true" CheckboxMode="CheckboxSelectionType.ResetOnRowClick"></GridSelectionSettings>
<SfDataManager Url="odata/Partner" Adaptor="Adaptors.ODataV4Adaptor"></SfDataManager>
<GridEvents TValue="Partner" RowSelected="RowSelected" OnToolbarClick="((context) => ToolbarClickHandler(context))"></GridEvents>
<GridColumns>
<GridColumn Field=@nameof(Partner.Name) Width="150"></GridColumn>
<GridColumn Field=@nameof(Partner.ShortName) Width="150"></GridColumn>
<GridColumn Field=@nameof(Partner.PartnerCode) Width="150"></GridColumn>
<GridColumn Field=@nameof(Partner.UUID) Visible="false" IsPrimaryKey="true" HeaderText="UUID" AllowEditing="false" Width="150"></GridColumn>
<GridColumn Field=@nameof(Partner.IsDeleted) Visible="false" HeaderText="IsDeleted" Width="150"></GridColumn>
</GridColumns>
</SfGrid>
The issue persisted until I changed the ID="partnerID" property to something else.
Im not sure why, but updating the ID value resolved the problem. Im not using the same ID elsewhere and if i give a totaly random value like prtID, it works.
I'm unsure why this resolved the issue and i couldn't reproduce the same behavior in your example, but after changing the ID field, everything is working as expected.
Thank you very much for your help!
Hi Szabolcs,
Welcome. We are glad to hear that the reported issue was resolved after changing the ID property. We suspect that the issue may have occurred due to a conflict between the older version and the latest Nuget version. Therefore, we suggest changing the ID property or alternatively, you can try clearing the local storage by calling ResetPersistData and check the reported issue at our end.
State Management in Blazor DataGrid Component | Syncfusion
Kindly get back to us if you have further queries.
Regards,
Monisha