Filterable operators in grouped columns

12 posts, 1 answers
  1. Andreas
    Andreas avatar
    18 posts
    Member since:
    Aug 2007

    Posted 05 Sep 2019 Link to this post

     

    Hi,

    we use some grids where we have defined the filters that appear on the columns with:

    .Filterable(ftb => ftb.Mode(GridFilterMode.Row)
                    .Extra(true)
                    .Operators(operators => operators
                        .ForString(str => str.Clear()
                            .Contains(String.Format(SharedLocalizer["lblGridFilterContains"].Value))
                            .StartsWith(String.Format(SharedLocalizer["lblGridFilterBeginsWith"].Value))
                            .IsEqualTo(String.Format(SharedLocalizer["lblGridFilterIsEqual"].Value)))
                        .ForNumber(num => num.Clear()
                            .IsEqualTo(String.Format(SharedLocalizer["lblGridFilterIsEqual"].Value))
                            .IsGreaterThan(String.Format(SharedLocalizer["lblGridFilterGreaterThan"].Value))
                            .IsLessThan(String.Format(SharedLocalizer["lblGridFilterLessThan"].Value))
                            )
                        .ForDate(date => date.Clear()
                            .IsEqualTo(String.Format(SharedLocalizer["lblGridFilterIsEqual"].Value))
                            .IsGreaterThan(String.Format(SharedLocalizer["lblGridFilterGreaterThan"].Value))
                            .IsLessThan(String.Format(SharedLocalizer["lblGridFilterLessThan"].Value))
                            )
                        )
                )

     

    And it works great.

    The problem is that when there are grouped columns it works in the "normal" columns but not in the grouped ones (it shows all the filters and not the ones we've defined).

    The only way we have found to make it work in every column is to define again in the column that's grouped the filterable operator:

    c.Group(group => group
                .Title(@SharedLocalizer["lblPaymentdiscountday2"].Value)
                .HeaderHtmlAttributes(new { groupname = "paymentsGrid_grp_skonto2" })            
                .Columns(skonto2 =>
                {
                    skonto2.Bound(m => m.discountday_2).HtmlAttributes(new { style = "text-align: right;" }).Width(90)
                    .Filterable(f => f
                        .Cell(cell => cell.Enabled(true).MinLength(100))
                        .Operators(op => op
                                .ForNumber(num => num.Clear()
                                        .IsEqualTo(String.Format(SharedLocalizer["lblGridFilterIsEqual"].Value))
                                        .IsGreaterThan(String.Format(SharedLocalizer["lblGridFilterGreaterThan"].Value))
                                        .IsLessThan(String.Format(SharedLocalizer["lblGridFilterLessThan"].Value))
                                        ))
                        );                
                    skonto2.Bound(m => m.discount_2).HtmlAttributes(new { style = "text-align: right;" }).Format(@SharedLocalizer["gridColumnFormatDec"].Value).Width(100).Filterable(f => f.Cell(cell => cell.Enabled(true).MinLength(100)));
                    skonto2.Bound(m => m.netday).HtmlAttributes(new { style = "text-align: right;" }).Width(90).Filterable(f => f.Cell(cell => cell.Enabled(true).MinLength(100)));

                })
            );

     

    We'd like to know if there's another way to make the custom filters work in grouped columns, because we'd like to avoid writing the same code for every grouped column in the grid.

    Thank you in advance.

    Kind regards

  2. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    2062 posts

    Posted 10 Sep 2019 Link to this post

    Hello,

    Actually it is absolutely possible to defined the Filterable option with the operators for each type outside the columns definition - on root level of the grid configuration. This way there is no need to define same filterable configuration for each group of columns. Please refer to the code snippet below: 

    @(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.CustomerViewModel>()
        .Name("grid")
        .Columns(columns =>
        {
        .....
        })
        .Filterable(ftb => ftb.Mode(GridFilterMode.Row)
            .Extra(true)
            .Operators(operators => operators
                .ForString(str => str.Clear()
                    .Contains("custom string")
                    .StartsWith("custom starts with")
                    .IsEqualTo("custom is equal")
                )
                .ForNumber(num => num.Clear()
                    .IsEqualTo("custom number is equal")
                    )
                .ForDate(date => date.Clear()
                    .IsEqualTo("custom date is equal")
                    )
                )
        )


    Regards,
    Boyan Dimitrov
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Andreas
    Andreas avatar
    18 posts
    Member since:
    Aug 2007

    Posted 12 Sep 2019 in reply to Boyan Dimitrov Link to this post

    Hi, thank you for the response.

     

    That's how we defined the filters in every grid. We encounter a problem when the grid has grouped columns.

    (First code block of the original post)

     

    How you can see in the GroupedColumn.jpg, when filtering, we can see all the filters and not only the ones we have defined. In the NormalColumn.jpg its a no grouped column (with the same type as the other) from the same grid, and like you can see it works as intended.

    The only way we have found that it works is to define the .filterable in a column basis, but we'd like to avoid that and use the configuration in the root level of the grid.

    In the GroupedColumn_filterableDefinedByColumn.jpg you can see the same column of the first example, but this time with the .filterable defined in the column and it works.

    (second code block of the original post)

    Is this a bug or are we missing something?

     

    Thank you

    Kind regards

     

  4. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    2062 posts

    Posted 17 Sep 2019 Link to this post

    Hello,

    I prepared a sample project that has a group column that includes ProductName and UnitsInStock columns. There is also custom filter operators for the string type on root level of the grid configuration. When I open the filter menu for the ProductName (string type of column) only "custom contains" operator is shown.  

    If the problem exists with specific configuration or project please send us a sample runnable project that replicates the problem so we can investigate it thoroughly. 

    Regards,
    Boyan Dimitrov
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  5. Andreas
    Andreas avatar
    18 posts
    Member since:
    Aug 2007

    Posted 18 Sep 2019 in reply to Boyan Dimitrov Link to this post

    Hi, thank you for your response.

    I've tried to download your attachment but I get always an 404 error.

    Could you upload it again?

    Thank you in advance.

  6. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    2062 posts

    Posted 18 Sep 2019 Link to this post

    Hello,

    I reattached the project in my reply from 17th of September so it should be downloaded without any problem. Please download ajax-binding-1428344.zip. 

     

    Regards,
    Boyan Dimitrov
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  7. Andreas
    Andreas avatar
    18 posts
    Member since:
    Aug 2007

    Posted 17 Oct 2019 in reply to Boyan Dimitrov Link to this post

    Hi, sorry for the late response.

    We tried your code, but we get the same behaviour as with our project.

    In the not grouped columns the custom filters work perfectly, but in a column that's grouped, they don't and we see the complete list of default filters.

     

  8. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    2062 posts

    Posted 22 Oct 2019 Link to this post

    Hello,

    I am sorry to hear that you are still facing the problem. 

    Actually I did try to run the attached project again and it worked fine. Also I asked one of my colleague to run the project on his machine to see if there is any difference when the project is run on different machine.  It worked in the same way and the custom filter message is applied for normal and group columns as well. 

    Based on the provided screenshots I noticed that there is a custom operator for number type. Could you please send the modified version of the project to check it locally at my side. 

    Regards,
    Boyan Dimitrov
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  9. Andreas
    Andreas avatar
    18 posts
    Member since:
    Aug 2007

    Posted 23 Oct 2019 in reply to Boyan Dimitrov Link to this post

    Hi,

    Here you have the project.

    PS: Just rename the file to .zip, I could not attach files other than .jpg, .jpeg, .gif, or .png

    Thank you, 
    Kind regards.

  10. Answer
    Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    2062 posts

    Posted 25 Oct 2019 Link to this post

    Hello,

    Indeed this is rather a bug when some other culture on server-side different from the "en-US". I guess that your culture on the server is "de-DE" (maybe is not explicitly set to be German, but the environment culture is German culture). When I set a German culture on the server-side I faced your problem. In group columns I got all operators for a specific type, but in normal column only the custom filters for the same type. 

    I logged a bug in our public repository https://github.com/telerik/kendo-ui-core/issues/5364 where the issue can be tracked for any progress. 

    In the meantime as a workaround I would suggest to define custom filter operators in the columns definition. 

    Regards,
    Boyan Dimitrov
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  11. Andreas
    Andreas avatar
    18 posts
    Member since:
    Aug 2007

    Posted 21 Aug 2020 in reply to Boyan Dimitrov Link to this post

    Hi,

    ist there any progress regarding this bug?

    Best regards!

  12. Nikolay
    Admin
    Nikolay  avatar
    295 posts

    Posted 26 Aug 2020 Link to this post

    Hello Andreas,

    The bug in questions is still in progress, however, I uplifted its priority. Feel free to subscribe to the GitHub issue to receive updates directly in your email inbox.

    Regards,
    Nikolay
    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).

Back to Top