This is a migrated thread and some comments may be shown as answers.

Filterable operators in grouped columns

11 Answers 316 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andreas
Top achievements
Rank 1
Andreas asked on 05 Sep 2019, 02:17 PM

 

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

11 Answers, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 10 Sep 2019, 03:49 PM
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.
0
Andreas
Top achievements
Rank 1
answered on 12 Sep 2019, 12:14 PM

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

 

0
Boyan Dimitrov
Telerik team
answered on 17 Sep 2019, 12:11 PM
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.
0
Andreas
Top achievements
Rank 1
answered on 18 Sep 2019, 05:53 AM

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.

0
Boyan Dimitrov
Telerik team
answered on 18 Sep 2019, 02:35 PM

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.
0
Andreas
Top achievements
Rank 1
answered on 17 Oct 2019, 11:19 AM

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.

 

0
Boyan Dimitrov
Telerik team
answered on 22 Oct 2019, 11:24 AM

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.
0
Andreas
Top achievements
Rank 1
answered on 23 Oct 2019, 06:26 AM

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.

0
Accepted
Boyan Dimitrov
Telerik team
answered on 25 Oct 2019, 02:22 PM

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.
0
Andreas
Top achievements
Rank 1
answered on 21 Aug 2020, 12:57 PM

Hi,

ist there any progress regarding this bug?

Best regards!

0
Nikolay
Telerik team
answered on 26 Aug 2020, 10:32 AM

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).

Tags
Grid
Asked by
Andreas
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Andreas
Top achievements
Rank 1
Nikolay
Telerik team
Share this question
or