Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
265
Ignite UI -Grid Filtering Issue
posted

Hi,

 

While Filtering a Data From iggid using remote side filtering we came across the Following Issue.

 

An exception of type 'Infragistics.Web.Mvc.ParseException' occurred in Infragistics.Web.Mvc.dll but was not handled in user code

Additional information: Expression expected.

 

The data we used to filter are as follows,

 

Copy of SPA_BTS_Test_20171003_V1.xlsx imported within Project.code-codecio : Failure - 5 error(s)

 

 

while we tried to paste the above string in filter its shows no exception error , but for testing we tried to paste the same  above error simultaneously two times without any delay

we face that above Exception.

 

The source we used are as follows,

 

   public IQueryable ApplyFilterExpr(NameValueCollection queryString, IQueryable customers)

        {

            List exprs = GetFilterExpressions(queryString);

            StringBuilder builder = new StringBuilder();

            int count = 0;

 

            for (int i = 0; i < exprs.Count; i++)

            {

                if (count != 0 && count <= exprs="" count="" -="" 1="" b="">

                {

                    builder.Append(exprs[i].Logic.ToLower() == "AND".ToLower() ? " AND " : " OR ");                   

                }

                count++;

 

                string condition = exprs[i].Condition;

                string expr = exprs[i].Expr;

                string colKey = exprs[i].Key;

                //string isNumeric=false;

                var dt = DateTime.Now;

 

                switch (condition.ToLower())

                {

                    case "startswith":

                        builder.Append(colKey + ".ToLower().StartsWith(\"" + expr.ToLower() + "\")");

                        break;

                    case "contains":

                        builder.Append(colKey + ".ToLower().Contains(\"" + expr.ToLower() + "\")");

                        break;

                    case "endswith":

                        builder.Append(colKey + ".ToLower().EndsWith(\"" + expr.ToLower() + "\")");

                        break;

                    case "equals":

                        if (colKey == "ShipName")

                        {

                            //col type is string

                            builder.Append(colKey + ".ToLower() == \"" + expr.ToLower() + "\"");

                        }

                        else

                        {

                            //col type is number

                            builder.Append(colKey + " == " + expr);

                        }

 

                        break;

                    case "doesnotequal":

                        if (colKey == "ShipName")

                        {

                            //col type is string

                            builder.Append(colKey + ".ToLower() != \"" + expr.ToLower() + "\"");

                        }

                        else

                        {

                            //col type is number

                            builder.Append(colKey + " != " + expr);

                        }

                        break;

                    case "doesnotcontain":

                        builder.Append("! " + colKey + ".ToLower().Contains(\"" + expr.ToLower() + "\")");

                        break;

                    case "lessthan":

                        builder.Append(colKey + " < " + expr);

                        break;

                    case "greaterthan":

                        builder.Append(colKey + " > " + expr);

                        break;

                    case "lessthanorequalto":

                        builder.Append(colKey + " <= " + expr);

                        break;

                    case "greaterthanorequalto":

                        builder.Append(colKey + " >= " + expr);

                        break;

                    case "on":

                        dt = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(double.Parse(expr)).ToUniversalTime();

                       builder.Append("(" + colKey + ".Value.Day == " + dt.Day + " AND " + colKey +

                           ".Value.Year == " + dt.Year + " AND " + colKey + ".Value.Month == " + dt.Month + ")");

                        break;

                    case "noton":

                        dt = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(double.Parse(expr)).ToUniversalTime();

                        builder.Append("!(" + colKey + ".Value.Day == " + dt.Day + " AND " + colKey +

                           ".Value.Year == " + dt.Year + " AND " + colKey + ".Value.Month == " + dt.Month + ")");

                        break;

                    case "after":

                        dt = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(double.Parse(expr)).ToUniversalTime();

                        builder.Append("((" + colKey + ".Value.Year > " + dt.Year + " OR (" +

                           colKey + ".Value.Month > " + dt.Month + " AND " + colKey + ".Value.Year == " + dt.Year + ") OR (" +

                           colKey + ".Value.Day > " + dt.Day + " AND " + colKey + ".Value.Year == " + dt.Year + " AND " +

                           colKey + ".Value.Month == " + dt.Month + ")))");

                        break;

                    case "before":

                        dt = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(double.Parse(expr)).ToUniversalTime();

                        builder.Append("((" + colKey + ".Value.Year < " + dt.Year + " OR (" +

                                       colKey + ".Value.Month < " + dt.Month + " AND " + colKey + ".Value.Year == " + dt.Year + ") OR (" +

                                       colKey + ".Value.Day < " + dt.Day + " AND " + colKey + ".Value.Year == " + dt.Year + " AND " +

                                       colKey + ".Value.Month == " + dt.Month + ")))");

                        break;

                    case "today":

                        builder.Append("(" + colKey + ".Value.Day == " + DateTime.Now.Day + " AND " + colKey +

                         ".Value.Year == " + DateTime.Now.Year + " AND " + colKey + ".Value.Month == " + DateTime.Now.Month + ")");

                        break;

 

                    case "yesterday":

                        DateTime yesterday = DateTime.Now.AddDays(-1);

                        builder.Append("(" + colKey + ".Value.Day == " + yesterday.Day + " AND " + colKey +

                         ".Value.Year == " + yesterday.Year + " AND " + colKey + ".Value.Month == " + yesterday.Month + ")");

                        break;

                    case "thismonth":

                        builder.Append("(" + colKey + ".Value.Year == " + DateTime.Now.Year + " AND " + colKey

                            + ".Value.Month == " + DateTime.Now.Month + ")");

                        break;

                    case "lastmonth":

                        builder.Append("(" + colKey + ".Value.Year == " + (DateTime.Now.Year) + " AND "

                        + colKey + ".Value.Month == " + (DateTime.Now.Month - 1) + ")");

                        break;

                    case "nextmonth":

                        builder.Append("(" + colKey + ".Value.Year == " + (DateTime.Now.Year) + " AND "

                            + colKey + ".Value.Month == " + (DateTime.Now.Month + 1) + ")");

                        break;

                    case "thisyear":

                        builder.Append(colKey + ".Value.Year == " + DateTime.Now.Year);

                        break;

                    case "lastyear":

                        builder.Append(colKey + ".Value.Year == " + (DateTime.Now.Year - 1));

                        break;

                    case "nextyear":

                        builder.Append(colKey + ".Value.Year == " + (DateTime.Now.Year + 1));

                        break;

                    case "true":

                        builder.Append(colKey + " == " + true);

                        break;

                    case "false":

                        builder.Append(colKey + " == " + false);

                        break;

                    default:

                        break;

                }

            }

            if (builder.Length > 0)

            {

                customers = customers.Where(builder.ToString(), new object[0]);

            }

 

            return customers;

        }

 

        internal List GetFilterExpressions(NameValueCollection queryString)

        {

            List expressions = new List();

            // check the query string for sorting expressions

            foreach (string key in queryString.Keys)

            {

                if (!string.IsNullOrEmpty(key) && key.StartsWith("filter("))

                {

                    string columnKey = key.Substring(key.IndexOf("(")).Replace("(", "").Replace(")", "");

                    string logic = "";

 

                    if (queryString["filter"] != null && (queryString["filter"].ToLower() == "and" || queryString["filter"].ToLower() == "or"))

                    {

                        logic = queryString["filter"];

                    }

 

                    Regex filtersRegex = new Regex(@"[a-z]+\(.*?\)", RegexOptions.IgnoreCase);

                    MatchCollection m = filtersRegex.Matches(queryString[key]);

                    string[] filters = new string[m.Count];

                    int i = 0;

                    foreach (Match capture in m)

                    {

                        filters[i] = capture.Value;

                        i++;

                    }

 

                    // Handle multiple filters for the same column

                    for (i = 0; i < filters.Length; i++)

                    {

                        FilterExpression e = new FilterBLOCKED EXPRESSION;

                    }

                }

            }

 

            return expressions;

        }

 

  • 5513
    Offline posted

    Hello,

    This is caused by the presence of brackets ( or ) in the searched string. We already have this in our internal system as a bug with #241738 and a fix will be available with the upcoming 17.2 release. As you are using 17.1, I updated the internal item so that it gets resolved for this major version as well. A support case is created on your behalf with number CAS-188030-D9Z1Q8, so that you can be notified when the bug is fixed. You can find your active cases under Account - Support Activity in our website. Select your ticket and go to Development Issues tab to view the status of related bugs.

    I will update you through the newly created support case should there be any additional information regarding the issue. Thank you for using Infragistics forums!

    Best regards,

    Stamen Stoychev