Good morning,
I have Grid with a Odata 4V controller as back end and my entity is :
-Name
-Surname
-DateBirth
My Odatacontroller map the entity to this model:
-Name
-Surname
-DateBirth
-RangeToSelect
RageToSelect is our logical view, it' a static list, is it possible to disable automatic filter to call my backend because "RangeToSelect" does not exist on my backend and how to edit the request for my back before send it?
Hi Galvy,
Greetings from Syncfusion support.
We suspect that you are expecting to cancel/customize the inbuilt filter request. If so we suggest you to use ActionBegin event and we can get the filtering action by checking the request type. By setting args.cancel as true will prevent the inbuilt filtering and also we can modify the filter request here. Kindly refer the below code snippet for your reference.
|
<SfGrid TValue="EmployeeData" ID="Grid" AllowPaging="true" AllowFiltering="true"> <GridEvents OnActionBegin="Begin" TValue="EmployeeData"></GridEvents> <SfDataManager Url=https://services.odata.org/V4/Northwind/Northwind.svc/Orders/ Adaptor="Adaptors.ODataV4Adaptor"></SfDataManager> <GridColumns> <GridColumn Field=@nameof(EmployeeData.OrderID) TextAlign="TextAlign.Center" HeaderText="Order ID" Width="120"></GridColumn> <GridColumn Field=@nameof(EmployeeData.CustomerID) TextAlign="TextAlign.Center" HeaderText="Customer Name" Width="130"></GridColumn> <GridColumn Field=@nameof(EmployeeData.EmployeeID) TextAlign="TextAlign.Center" HeaderText="Employee ID" Width="120"></GridColumn> </GridColumns> </SfGrid>
@code { public void Begin(ActionEventArgs<EmployeeData> args) { if (args.RequestType == Syncfusion.Blazor.Grids.Action.Filtering) { args.Cancel = true; // by setting args.cancel will prevent the default filtering action or you can modify the request here. } } public class EmployeeData { public int OrderID { get; set; } public string CustomerID { get; set; } public int EmployeeID { get; set; } } } |
Reference: https://blazor.syncfusion.com/documentation/datagrid/events#onactionbegin
Please let us know if you have any concerns.
Regards,
Monisha
Thanks, that's exactly what I was thinking of.
You can also show me how to modify the request and then forward it to back end
Hi Galvy,
We would like to inform you that in DataGrid filtering will takes place based on the columns (i.e. if customerId column is filtered then the request is raised only for the current column) and it will not carry details of other column in the generated request and we suspect that your Grid has 4 columns and the controller has 3 columns and you are expecting to prevent filtering for the RangeToSelect column. If so we would like to inform that we can prevent the column level filtering by setting AllowFiltering property as false or you can set args.cancel as true only for the particular column. Kindly check the below attached code snippet and documentation for your reference.
|
<SfGrid TValue="EmployeeData" ID="Grid" AllowPaging="true" AllowFiltering="true"> <GridEvents OnActionBegin="Begin" TValue="EmployeeData"></GridEvents> <SfDataManager Url=https://services.odata.org/V4/Northwind/Northwind.svc/Orders/ Adaptor="Adaptors.ODataV4Adaptor"></SfDataManager> <GridColumns> <GridColumn Field=@nameof(EmployeeData.OrderID) TextAlign="TextAlign.Center" HeaderText="Order ID" Width="120"></GridColumn> <GridColumn Field=@nameof(EmployeeData.CustomerID) TextAlign="TextAlign.Center" HeaderText="Customer Name" Width="130"></GridColumn> <GridColumn Field=@nameof(EmployeeData.EmployeeID) AllowFiltering="false" TextAlign="TextAlign.Center" HeaderText="Employee ID" Width="120"></GridColumn> </GridColumns> </SfGrid>
@code { public void Begin(ActionEventArgs<EmployeeData> args)
{
if (args.RequestType == Syncfusion.Blazor.Grids.Action.Filtering)
{ if(args.CurrentFilteringColumn == "EmployeeID") { args.Cancel = true; }
}
} |
Reference: Data Binding in Blazor DataGrid Component | Syncfusion
If we misunderstood your query or if you have further queries then kindly get back to us with an video demonstration of the query or if possible share us an simple issue replicating sample.
Regards,
Monisha