Hello,
I am using the Syncfusion grid with an WebAPI adaptor with a custom ODataV4 data manager to fetch data. Currently when I search using the search toolbar it applies a "contains" filter to each column with the datatype being string (even for columns that are numerical). Is there a way to allow the ODataV4 to search on numerical columns as well as string columns?
Thank you,
Josh Goughnour
Hi Monisha,
Below is the requested information
Grid Setup
Column setup
Startup
CustomOData Adaptor
The search string is returning a contains on each column, including the column with a number type.
Thank you,
Josh G.
|
public class CustomODataV4 : WebApiAdaptor
{
public override string OnPredicate(WhereFilter filter, DataManagerRequest query, bool requiresCast = false)
{
ODataV4Adaptor customAdaptor = new ODataV4Adaptor(dm);
//RemoteOptions Rm = customAdaptor.Options;
//Rm.EnableODataSearchFallback = true;
//customAdaptor.Options = Rm;
return customAdaptor.OnPredicate(filter, query, requiresCast);
}
}
protected override void OnAfterRender(bool firstRender)
{
base.OnAfterRender(firstRender);
if (DM != null)
{
#pragma warning disable BL0005
DM.DataAdaptor = new CustomODataV4(DM);
#pragma warning restore BL0005
}
RemoteOptions Rm = (DM.DataAdaptor as WebApiAdaptor).Options;
Rm.EnableODataSearchFallback = true;
(DM.DataAdaptor as WebApiAdaptor).Options = Rm;
}
|
Thank you for the response!
It looks like that took care of the issue. I have 2 last questions related to this.
1) is it possible to override the number column with a less than or greater than filter?
2) Currently the OData filter query is all lowercase. Is it possible to make this filter case sensitive?
Thank you,
Josh G.
How exactly would I force the data manager to use tolower() instead of just making the string all lowercase?
Example of how the query string currently looks:
(tolower(Inchi) eq 'inchi1s/hno3/c2-1(3)4/h(h,2,3,4)')
How I would like it to look:
(tolower(Inchi) eq 'InChI1S/HNO3/c2-1(3)4/h(h,2,3,4)')
Thank you,
Josh G.
|
public class CustomODataV4 : WebApiAdaptor
{
public DataManager dm { get; set; }
public CustomODataV4(DataManager dataManager) : base(dataManager)
{
dm = dataManager;
}
public override string OnPredicate(WhereFilter filter, DataManagerRequest query, bool requiresCast = false)
{
ODataV4Adaptor customAdaptor = new ODataV4Adaptor(dm);
return customAdaptor.OnPredicate(filter, query, requiresCast);
}
public override void BeforeSend(HttpRequestMessage request)
{
//here you will get entire uri string. kindly mdify the string as per your requirement
if (request.RequestUri.AbsoluteUri.Contains("tolower"))
{
var check = request.RequestUri.AbsoluteUri.Replace("tolower", "toupper");
var updatedUri = new Uri(check);
request.RequestUri = updatedUri;
}
//and send to the BeforeSend method.
base.BeforeSend(request);
}
} |