Unplanned
Last Updated: 11 Jan 2021 14:35 by ADMIN
Jaroslav
Created on: 13 Dec 2019 16:42
Category: UI for ASP.NET MVC
Type: Feature Request
1
FilterDescriptorFactory does not cover exponential values case (for example "1e-9")

Description 

I am restoring the filter for a Kendo Grid in a Controller from a stored filter string. When there is an exponential (e.g. 1e-9) as a value, FilterDescriptoractory.Create() throws an exception "Expected RightParenthesis". Looking at the filter string it seems to have the correct number of parentheses.

On some occasions exponentials work but I can not determine under which. Under which conditions will exponentials work in filters?

Example 

var filterString = "ShipName~eq~'ShipName1'~and~(Freight~eq~0~or~Freight~gte~1e-9)~and~ShipCity~gt~0";
var filters = FilterDescriptorFactory.Create(filterString);

5 comments
ADMIN
Veselin Tsvetanov
Posted on: 09 Jan 2020 07:22

Hello Jaroslav,

Thank you for the additional information provided.

As the exponentials were not considered at all in the filter expression implementation, I would consider the discussed case to be a missing functionality in the utility, rather than a bug in its implementation. Therefore, I have changed the type of the current thread to Feature request. Also, just to be clear to other members of the community, I have altered slightly the title of the thread.

Regards,
Veselin Tsvetanov
Progress Telerik

Get quickly onboarded and successful with your Telerik UI for ASP.NET MVC with the dedicated Virtual Classroom technical training, available to all active customers.
Jaroslav
Posted on: 02 Jan 2020 11:45

Hi Veselin,

It turns out that exponentials actually don't work, even when no exception is thrown.

The simplest case with
var filterString = "Freight~eq~1e-9";

is parsed without exception, but it turns out that the expression is truncated after the "1", so the filter becomes "Freight~eq~1".

The same if you try with a longer expression without parentheses, like
var filterString = "ShipName~eq~'ShipName1'~and~Freight~eq~1e-9~or~Freight~gte~0~and~ShipCity~gt~0";

which is interpreted as "ShipName~eq~'ShipName1'~and~Freight~eq~1"

Regards,
Jaroslav 

ADMIN
Veselin Tsvetanov
Posted on: 27 Dec 2019 08:15

Hi Jaroslav,

Thank you for the additional info provided, which helped me replicate the issue in question.

By now the filter descriptor has not been tested with exponential number representation. Having that said, can you share a filter string containing an exponential that would not result in the error in question? That would allow us to analyze the differences in the two cases. So far the case seems a scenario, which has not been considered and covered in the filter implementation.

Regards,
Veselin Tsvetanov
Progress Telerik

Get quickly onboarded and successful with your Telerik UI for ASP.NET MVC with the dedicated Virtual Classroom technical training, available to all active customers.
Jaroslav
Posted on: 20 Dec 2019 12:46

Hi,

You can copy the above lines into any controller in a Kendo application. (I used the default Kendo application from the New project template.)

using System;
using System.Linq;
using System.Web.Mvc;
using Kendo.Mvc.Extensions;
using Kendo.Mvc.Infrastructure;
using Kendo.Mvc.UI;
using TelerikMvcApp1.Models;
namespace TelerikMvcApp1.Controllers
{
 public partial class GridController : Controller
    {
  public ActionResult Orders_Read([DataSourceRequest]DataSourceRequest request)
  {
   var result = Enumerable.Range(0, 50).Select(i => new OrderViewModel
   {
    OrderID = i,
    Freight = i * 10,
    OrderDate = DateTime.Now.AddDays(i),
    ShipName = "ShipName " + i,
    ShipCity = "ShipCity " + i
   });
      try
      {
          var filterString =
                    "ShipName~eq~'ShipName1'~and~(Freight~eq~1e-9~or~Freight~gte~0)~and~ShipCity~gt~0";
          var filters = FilterDescriptorFactory.Create(filterString);
          request.Filters = filters;
      }
      catch (Exception ex)
      {
          return Json(ex.Message);
      }
      return Json(result.ToDataSourceResult(request));
  }
 }
}
ADMIN
Petar
Posted on: 20 Dec 2019 11:47

Hi Jaroslav,

Thank you for reporting the issue. To be able to confirm that the reported behavior is a bug or a supported/unsupported functionality we should be able to reproduce the case and investigate it.

Can you provide a runnable example + step-by-step instructions for reproducing the reported behavior?

Looking forward to your reply.

Regards,
Petar
Progress Telerik

Get quickly onboarded and successful with your Telerik UI for ASP.NET MVC with the dedicated Virtual Classroom technical training, available to all active customers.