Remove Substringof from $filter - Autocomplete

I'm trying to implement the webapiadaptor autocomplete and use a datasource that is a function call

Untitled1.png


Untitled2.png


And everything works fine except when I type '123' $filter returns

$filter=substringof(%2527123%2527,tolower(text))

How do I get it so that $filter=123


3 Replies

SP Sureshkumar P Syncfusion Team July 18, 2022 04:29 AM UTC

Hi Nathan,

Bu default in our WebApiAdaptor, the $filter query returns with substring it was the default behavior as per our current architecture. We cannot remove the substring from the filter query. Please refer to the below screenshot for more information.

Screenshot:

Filter Query for number column

Filter Query for string column

Regards,

Sureshkumar P



NM Nathan Munson replied to Sureshkumar P July 21, 2022 03:52 PM UTC

So since this is the default behavior what is your recommendation on how to handle this in the controller then?

Is there a way to decode it? Can we customize the $filter value when it makes the request to the controller?


Our current solution is -

value = value.Substring(0, value.Length - 16);

value = value.Remove(0, 13);


Which just seems sloppy to us, and potentially error prone



PS Pavithra Subramaniyam Syncfusion Team July 25, 2022 03:10 PM UTC

Hi Nathan,


You can customize the default API request before a request is made by overriding the “processQuery” method using the “Custom Adaptor”. Please refer to the below code example and documentation link for more information.


function created(args) {

  class CustomAdaptor extends ej.data.WebApiAdaptor {

    processQuery(dm, query, hierarchyFilters) {

      // Executing base class processQuery function

      let original = super.processQuery.apply(this, arguments);

      // Here you can customize the request as per your need and send it

      return original;

    }

  }

  var grid = document.querySelector('#Grid').ej2_instances[0];

  grid.dataSource = new ej.data.DataManager({

    url: hostUrl + 'api/Orders',

    adaptor: new CustomAdaptor(),

  });

}

 


https://ej2.syncfusion.com/aspnetmvc/documentation/grid/data-binding/remote-data#custom-adaptor


Please get back to us if you need further assistance on this.


Regards,

Pavithra S


Loader.
Up arrow icon