ignoreCase false in ToDataSourceRequest()

3 Answers 64 Views
Grid
Carlos
Top achievements
Rank 2
Iron
Iron
Iron
Carlos asked on 06 Sep 2023, 11:28 AM

Hello,

im using kendo-react with .net core integration.

When i want to filter a Grid the query generated by the method: `toDataSourceRequest()`use the sql function LOWER to compare a string column.

With this behaviour its impossible to match only the exact rows. I want to disable this function and use the `=` operator in SQL.


I think if i use: `ignoreCase: false` in the frontend and then serialize with: `toDataSourceRequestString` from the `@progress/kendo-data-query` package, the `DataSourceRequest` will contain the ignoreCase prop and the toDataSourceRequest will do the job.

But the ignoreCase:false prop is not added to the query param,.

Any suggestion? Its not possible to use ignoreCase with the backend integration and only works in frontend?

https://codesandbox.io/s/vigorous-bush-s2fgnc => ignore case working when the filter is in frontend.

- https://codesandbox.io/s/nervous-platform-9nr2q4 => with backend not working

Thanks!

3 Answers, 1 is accepted

Sort by
0
Accepted
Alexander
Telerik team
answered on 11 Sep 2023, 11:01 AM

Hi Carlos,

Thank you for sharing the currently established scenario that is held on your premises. It really helps refine where exactly the issue might be pertaining from.

Based on my current understanding of the case, the current scenario utilizes an implementation similar to how it is described in the following resource:

Looking at the provided implementation, at this stage it appears that the DataSource request does not send arbitrary data to the provided backend service. You can verify this by observing how the FilterDescriptor class is composed and what properties it supplements upon filtering:

public partial class FilterDescriptor : FilterDescriptorBase
{

    public FilterDescriptor() : this(string.Empty, FilterOperator.IsEqualTo, null)
    {
    }

    
    public FilterDescriptor(string member, FilterOperator filterOperator, object filterValue)
    {
        this.Member = member;
        this.Operator = filterOperator;
        this.Value = filterValue;
    }

    public object ConvertedValue
    {
        get
        {
            return this.Value;
        }
    }

    
    public string Member
    {
        get;
        set;
    }

    
    public Type MemberType { get; set; }

    
    public FilterOperator Operator
    {
        get;
        set;
    }

  
    public object Value
    {
        get;
        set;
    }
}

In addition, a similar topic has been discussed in the following forum case: 

Although the aforementioned article tackles a Kendo UI DataSource, the same principles stand for the server-side incarnation as well.

Kind Regards,
Alexander
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages. If you're new to the Telerik family, be sure to check out our getting started resources, as well as the only REPL playground for creating, saving, running, and sharing server-side code.
0
Carlos
Top achievements
Rank 2
Iron
Iron
Iron
answered on 07 Sep 2023, 01:16 PM

If i use this custom FilterDescriptor:


public class FilterInsensibleDescriptor : FilterDescriptor
{
     protected override Expression CreateFilterExpression(ParameterExpression instance)
     {
           if (base.Operator == FilterOperator.IsEqualTo)
           {
                MemberExpression member = Expression.Property(instance, base.Member);
                return Expression.Equal(member, Expression.Constant(base.Value.ToString()));
           }

           return base.CreateFilterExpression(instance);
      }
}

The LambdaExpression generated is this: 

item.Name== "v533.19596.000.01"

But with the dafault FilterDescriptor:

item.Name.ToLower() == "V533.19596.000.01".ToLower()

0
Carlos
Top achievements
Rank 2
Iron
Iron
Iron
answered on 12 Sep 2023, 01:16 PM | edited on 12 Sep 2023, 01:18 PM

 

Hello alexander,

thank you for your reply.

I understand then that using the IQueryable.ToDataSourceResult( DataSourceRequest request) method it is not possible to filter in a case sensitive way. Am I right?

If there is any way or workaround (in backend) please let me know.

Best regards!

 

Alexander
Telerik team
commented on 15 Sep 2023, 10:51 AM

Hi Carlos,

Indeed, at this stage, the DataSourceRequest representation would not contain meta information that would include the "IgnoreCase" setting.

At this stage, my recommendation would be to extract the IgnoreCase information from the client-side component and pass it as a query string parameter for example to the Read method. However, our expertise revolves around the Telerik UI for ASP.NET Core Grid and not the Angular suite.

In this regard, I would personally recommend opening a new case if further assistance regarding the Kendo UI for Angular DataGrid is required. 

Tags
Grid
Asked by
Carlos
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Alexander
Telerik team
Carlos
Top achievements
Rank 2
Iron
Iron
Iron
Share this question
or