Column Filter & CustomAdaptor

Hi,

I am using CustomAdaptor. I used the following code for the default column filter, but unfortunately the filter does not apply.

<GridFilterSettings>

            <GridFilterColumns>

                 <GridFilterColumn Field="filedname" MatchCase=false Operator="Operator.StartsWith" Predicate="and" Value="@strDefaultFilter">

     </GridFilterColumn>

            </GridFilterColumns>

        </GridFilterSettings>


Thank you


7 Replies 1 reply marked as answer

RN Rahul Narayanasamy Syncfusion Team April 26, 2022 02:22 PM UTC

Hi Sarah,


Greetings from Syncfusion.


Based on your shared details we have checked the reported query. We could not able to reproduce the reported problem. The initial filter is applied correctly without any issues while using CustomAdaptor. Find the below sample for your reference.


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/SampleApp758724546


If you are still facing the problem, then could you please share the below details which will be helpful to validate and provide a better solution.


  • Video demonstration of the problem.
  • Full Grid code snippets.
  • Reproduce the problem in the provided sample and revert back to us.
  • Share a simple reproducible sample.


Regards,

Rahul



SA Sarah April 27, 2022 04:07 AM UTC

Hi Rahul Narayanasamy ,


I compared your source with my own source. When we use EnablePersistence = "true" the filter is no longer applied.


Thank you




RN Rahul Narayanasamy Syncfusion Team April 28, 2022 01:47 PM UTC

Hi Sarah,


Thanks for the update.


Based on your share details we have checked your reported case. We could not able to reproduce the reported problem. While using EnablePersistence, the filters are properly applied to the Grid without any issues. Find the below sample for your reference.


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Sample-1023944161


If you are still facing the problem, then could you please share the below details which will be helpful to validate and provide a better solution.


  • Reproduce the problem in the provided sample and revert back to us.
  • Syncfusion Blazor NuGet version details.
  • Full Grid code snippets.
  • Share a simple reproducible sample if possible.


Regards,

Rahul




SA Sarah replied to Rahul Narayanasamy April 30, 2022 03:56 AM UTC

Hi  Rahul Narayanasamy,


I downloaded the following source and the filter was not applied after running. The image is attached.


https://www.syncfusion.com/downloads/support/directtrac/general/ze/Sample-1023944161





MS Monisha Saravanan Syncfusion Team May 3, 2022 09:57 AM UTC

Hi Sarah,


Thanks for the update.


We have checked your query and we could not able to reproduce the reported query when using shared sample. Filtering works fine at our end. Kindly check the attached video demo for additional information.


Video: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Persistence-Issue2012943895.zip


Also we suggest you to check the reported issue after clearing Nuget and browser cache. And also check the reported issue after changing the ID property of the DataGrid.


If the reported issue still persist then kindly get back to us with an video demonstration of the issue.


Regards,

Monisha



SA Sarah August 17, 2023 06:39 AM UTC

HiMonisha Saravanan,

Thank you for your reply.

If we use DataSource like the source code below. How to edit the data entered by the user before the DataGrid filter. For example, I want to edit the characters of the user "a" to "b" and then apply the filter to the DataGrid. As another example, convert two spaces into one space. Or convert a semispace to a space.


<SfGrid DataSource="@Orders" AllowPaging="true">

    <GridPageSettings PageSize="5"></GridPageSettings>

    <GridColumns>

        <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Right" Width="120"></GridColumn>

        <GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="150"></GridColumn>

        <GridColumn Field=@nameof(Order.OrderDate) HeaderText="Order Date" Format="d" Type="ColumnType.DateOnly" TextAlign="TextAlign.Right" Width="130"></GridColumn>

        <GridColumn Field=@nameof(Order.OrderTime) HeaderText="Order Time" Type="ColumnType.TimeOnly" TextAlign="TextAlign.Right" Width="130"></GridColumn>

        <GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn>

    </GridColumns>

</SfGrid>




MS Monisha Saravanan Syncfusion Team August 17, 2023 12:27 PM UTC


Hi Sarah,


Query: “How to edit the data entered by the user before the DataGrid filter. For example, I want to edit the characters of the user "a" to "b" and then apply the filter to the DataGrid.”


We would like to inform that we can prevent the inbuilt filtering by setting args.Cancel  as true in the ActionBegin event for the request type filtering and we can customize the entered input and perform our own filter using FilterByColumnAsync method.


Here in the below code snippet we have changed the input value to “b” and performed filtering using FilterByColumnAsync method. Kindly refer the attached sample and code snippet for your reference.


 

<SfGrid DataSource="@Orders" @ref="Grid" AllowPaging="true" AllowFiltering="true">

    <GridEvents OnActionBegin="ActionBeginHandler" TValue="Order"></GridEvents>

    <GridColumns>

 

    </GridColumns>

</SfGrid>

 

@code {

    public SfGrid<Order> Grid { get; set; }

    public List<Order> Orders { get; set; }

 

 

    public bool _isFiltered { get; set; } = false;

    public async Task ActionBeginHandler(ActionEventArgs<Order> args)

    {

        if (args.RequestType == Syncfusion.Blazor.Grids.Action.Filtering && !_isFiltered)

        {

            _isFiltered = true;

            args.Cancel = true;

            string field = args.CurrentFilterObject.Field;

            string operatorval = args.CurrentFilterObject.Operator.ToString().ToLower();

            string val = "b"; // ypu can modify the value here

            await Grid.FilterByColumnAsync(field, operatorval, val);

 

        }

    }

 

}


Kindly get back to us if you have further queries.


Attachment: BlazorApp1_cb4489d5.zip

Marked as answer
Loader.
Up arrow icon