Duplicated
Last Updated: 03 Nov 2020 20:48 by Andrew
David Ocasio
Created on: 21 Oct 2020 15:20
Category: Grid
Type: Bug Report
3
ToODataString extension method generates incorrect request URL when sorting/filtering the Grid

On initialization of the Grid the oDataString is correct, but when I apply a filter or apply a sort to a Grid column the ToODataString extension method generates an incorrect request URL. If I revert back to 2.16.0 everything works as expected. 

Duplicated
This item is a duplicate of an already existing item. You can find the original item here:
2 comments
Andrew
Posted on: 03 Nov 2020 20:48
This bug seems different from the one marked as a duplicate. In that case the reporter was getting a NullReferenceException, this is reporting bad output with no NullReferenceException.

If anyone else stumbles across this looking for a workaround I used some string manipulation to remove the invalid eq and contains parts of the query string. It's not pretty but it works for us:



      private static readonly Regex emptyContainsClause = new Regex(@"((?<=\()|%20and%20)(contains\([\w]+,%27%27\)(%20and%20|(?=\))))+", RegexOptions.Compiled);
      private static readonly Regex emptyEqualsClause = new Regex(@"((?<=\()|%20and%20)([\w]+%20eq%20(%20and%20|(?=\))))+", RegexOptions.Compiled);
      private static string FixODataEmptyContainsBug(string odataString)
      {
         // Telerik Blazor 2.17.0 has a bug with FilterMenu that causes it to append invalid empty clauses for every filterable field
         odataString = emptyContainsClause.Replace(odataString, "");
         odataString = emptyEqualsClause.Replace(odataString, "");
         odataString = odataString.Replace("()", "true")
            .Replace("true%20and%20", "")
            .Replace("%20and%20true", "")
            .Replace("&$filter=()", "");
         return odataString;
      }
ADMIN
Svetoslav Dimitrov
Posted on: 21 Oct 2020 15:31

Hello,

Using FilterRow instead of FilterMenu seems to resolve the issue. For now, I am marking this thread is duplicate to another bug report we have.

Regards,
Svetoslav Dimitrov
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).