Angular 2 Kendo grid not supporting odata v4

I tried server side filtering using angular 2 kendo grid with odata v4 but showing the "contains" keyword is not supported. new version using 'substringof' instead of 'contains' how can i solve this problem

+3


source to share


2 answers


Install Odata V4 and configure WebApiConfig.cs

 ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
                var customer = builder.EntitySet<CustomerModel>("CustomerSearch");

                config.Routes.MapODataServiceRoute(
                  routeName: "odata",
                  routePrefix: "odata",
                  model: builder.GetEdmModel());

      

'CustomerModel' is my model to return Controller name CustomerSearch



Odata controller

 [EnableQuery]
    public class CustomerSearchController : ODataController
    {

        [EnableQuery]
        public IQueryable<CustomerModel> Get()
        {
            CustomerModelResponse list = new CustomerModelResponse();
            try
            {
                list = CustomerBL.GetCustomer(0);
            }
            catch (Exception)
            {

                throw;
            }
            return list.CustomerList.AsQueryable();
        }

    }

      

0


source


We are using OData v3.

What I did was regex queryString if it has contains () then replace it with substringof ()

Here's an example:



  let queryString = toODataString(state);
  const regex = /(contains(([^)]+)\)))/;
  queryString = _.replace(queryString, regex, `substringof('${filter.value}', ${filter.field})`);

      

I am using lodash here but I also have to work with string.replace function

0


source







All Articles