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

Custom filter not working when culture is changed

19 Answers 563 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Juergen
Top achievements
Rank 1
Juergen asked on 02 Jul 2014, 07:34 AM
Hi there,

I'm using a custom filter for different data types. Actually, this works pretty well as long as I use 'en-US' as culture and I don't switch to another. The possibility of changing the culture is part of my application. When changing the culture to e.g. 'de-DE', the standard grid filter is displayed instead of my custom one. Switching back to 'en-US', everything works again like it should.

Below an example for one my grids and also how I change the culture in my application.

@(Html.Kendo().Grid(Model)
      .Name("FolderIndexGrid")
      .Pageable(e => e.PageSizes(new int[] {10, 20, 40, 80, 100}))
      .Sortable()
      .Filterable(f => f
          .Operators(g =>
              g.ForString(h =>
                {
                  h.Clear();
                  h.Contains(Resources.Resource.Contains);
                  h.DoesNotContain(Resources.Resource.DoesNotContain);
              })))
      .Scrollable(s => s.Height("auto"))
      .HtmlAttributes(new {@class = "maxHeight"})
      .RowAction(e =>
            {
                if (e.DataItem.Deleted)
                {
                    e.HtmlAttributes["style"] = "background-color:red;";
                }
            })
      .Columns(column =>
          {
              column.Bound(o => o.FileNr).Width(200).Title(Resources.FieldResource.FileNr)
                         .ClientTemplate(
                            
"<a href='" + Url.Action("Overview", "FileOverview") + "/#= FileNr #'" + ">#=FileNr#</a>"
                         );
              column.Bound(o => o.LovManufacturerId).Width(150).Title(Resources.FieldResource.LovManufacturerId);
              column.Bound(o => o.Name).Width(200).Title(Resources.FieldResource.FileName);
              column.Bound(o => o.Description);
              column.Template(@<text></text>).Title(Resources.FieldResource.Actions).Width(90)
                    .ClientTemplate(
                    "<a href=" + Url.Action("Overview", "FileOverview") + "/#= FileNr #" + ">
                               <img src=\"../../Content/images/zoom.png\" />
                           </a>"
+
                    "<a style=\"margin: 5px;\" href=" + Url.Action("Edit", "File") + "/#= FileNr #" + ">
                               <img src=\"../../Content/images/pencil.png\" />
                           </a>"
);
           }
      )
          .DataSource(dataSource => dataSource
                   .Ajax()
                   .Read(read => read.Action("Folder_Read", "Fetch", new { engineId = ViewBag.EngineId}))
                   .PageSize(40)
                   .Sort(sort => sort.Add("FileNr").Ascending()
          ))
          .ClientDetailTemplateId("detailview")
)

Changing the culture in _Layout.cshtml:
@{
    var culture = System.Threading.Thread.CurrentThread.CurrentCulture;
}
<script src="@Url.Content("~/Scripts/kendo/2014.1.528/cultures/kendo.culture." + culture + ".min.js")"></script>
<script>
    kendo.culture("@culture");
</script>

Best regards,
Jürgen

19 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 04 Jul 2014, 05:43 AM
Hello Juergen,

You mentioned that you are using custom filter however in your code I did not see custom UI function used. I tried your case on my side and the format of the datepicker is changed each time with the culture. Please have a look at the attached demo and if I missed something please modify the project and send it back.

Regards,
Petur Subev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Juergen
Top achievements
Rank 1
answered on 04 Jul 2014, 08:54 AM
Hi Petur,

I added a filter operator for strings and a language selector for German and English. You'll see that the filter operator does not apply when switching the language to German. Switching back to English the filter operator works like intended.
All modified files are attached.

Best regards,
Juergen
0
Petur Subev
Telerik team
answered on 07 Jul 2014, 09:25 AM
Hello Juergen,

I updated the project with the files that you shared, however when I click the German button in the layout page nothing happens, the culture remains the same. However when I change the culture within the webconfig all the messages are translated. It looks like the current culture is not updated when the buttons are clicked.

http://screencast.com/t/jc5ZFQV6R1

Check the attached project (I added culture message that shows the current culture at the top of the body element).

Let me know if I missed something.

Regards,
Petur Subev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Juergen
Top achievements
Rank 1
answered on 07 Jul 2014, 11:14 AM
Hi Petur,

you're right! I forgot my modified 'Global.asax.cs' file. Language selection should work now with the files attached.

So, when you start the application, open the filter menu for column 'Name'. When culture is set to English, the filter menu should give you a selection between 'Contains' and 'Does not contain' and nothing else. This works as it should.
But when switching to German, you'll see that the filter menu doesn't show you a selection between 'Contains' and 'Does not contain', but the complete list of compare operators instead, beginning with 'Ist gleich' ('Is equal to').

Best regards,
Juergen
0
Petur Subev
Telerik team
answered on 09 Jul 2014, 10:39 AM
Hello Juergen,

Thank you very much for sending the sample project. I managed to reproduce the issue here are the fact that cause this weird behavior
   - Grid renders messages for each of filterable columns when the culture is changed
   - the grid column.filterable configuration is with greater precedence over the grid.filterable configuration.

So the settings configured on the grid.filterable level got overridden by the one on the column.filterable level. So to avoid this you need to set the settings you need on the column.filterable level.

e.g.

@(Html.Kendo().Grid<KendoMVCWrappers.Models.Person>().Name("people")
    .DataSource(dataSource => dataSource
        .Ajax()
            .Model(model => {
                model.Id(m => m.PersonID);
                model.Field(m => m.PersonID).Editable(false);
            })
            .Batch(true)
            .Read(read => read.Action("GetPeople","Home"))
            .Update(up=>up.Action("UpdatePerson","Home"))
            .Create(up => up.Action("CreatePerson", "Home"))
    )
    .ToolBar(tb=>{
        tb.Save();
        tb.Create();
    })
    .Columns(columns =>
    {
    columns.Bound(c => c.PersonID);
    columns.Bound(c => c.Name).Filterable(f => f
            .Operators(g =>
                g.ForString(h =>
                {
                    h.Clear();
                    h.Contains("Contains");
                    h.DoesNotContain("Does not conatin");
                })));
    columns.Bound(c => c.BirthDate).Format("{0:d}");
    })
    .Editable(ed=>ed.Mode(GridEditMode.InCell))
    .Pageable()
    .Sortable()
    .Filterable()
    //.Filterable(f => f
    //        .Operators(g =>
    //            g.ForString(h =>
    //            {
    //                h.Clear();
    //                h.Contains("Contains");
    //                h.DoesNotContain("Does not conatin");
    //            })))
)

I am sorry for any inconvenience caused.

Kind Regards,
Petur Subev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Juergen
Top achievements
Rank 1
answered on 09 Jul 2014, 11:18 AM
Hi Petur,

thank you for your answer. Unfortunate to hear this is actually the only possible solution, especially when switching cultures with my grid.filterable configuration once worked with a 2013 Kendo UI version. Is this a bug or is this behaviour intentionally? If this is a bug, then I hope we'll see a fix in a future release.

I have a lot of grids in several applications, some with over 80 columns. Though this workaround is not that big a deal to implement in my dynamically created grids, I have to add column.filterable settings to each column manually in the static ones. This is not really easy to maintain should I have to change filter settings in the future.

Please tell me if it is being worked on to fix this, because I would'nt really enjoy to step down to a former Kendo UI version where this actually worked.

Best regards,
Juergen
0
Juergen
Top achievements
Rank 1
answered on 09 Jul 2014, 11:31 AM
Thinking over it again, I is still not entirely clear to me why after switching back to English grid filter settings are not overridden with columns filter settings the same way when switching to German.

Best regards,
Juergen
0
Petur Subev
Telerik team
answered on 10 Jul 2014, 12:26 PM
Hello again Juergen,

If the culture is not changed then the Grid does not serialize neither grid.filterable.messages nor grid.columns.fitlterable.messages (because they are the default one).
If the culture is changed then the Grid serialized both grid.filterable.messages and grid.columns.filterable.messages.

The column level filterable options are with higher precedence over the grid level filterable options, which means whatever you typed on the Grid level will be overridden by the column level options that are automatically serialized when the language is changed.

I have logged this into our internal system as an issue that neesd to be fixed, since you are the first one who falls into such case I cannot give concrete time interval in which it will be fixed.

Kind Regards,
Petur Subev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Lukáš
Top achievements
Rank 1
answered on 28 Sep 2016, 10:44 AM
Hello
apologies for reviving this rather old thread, but I believe I may be facing the same issue that is discussed here. Let me explain please. I am using Kendo version 2016.1.226 for out asp.net mvc application.The application has three cultures: en-US, cs-CZ and sk-SK. I am using default operators for strings, dates and numbers on my grids - the same way the OP described. The default operators are set on the grid level, eg. not for each column as the proposed solution suggests.
Like the OP, when culture is set to en-US, the default operators work fine. Oddly enough though, sk-SK culture works as well. Problem is when the culture is set to cs-CZ, the default operators just don't work - standard grid filters appear. Everything in cs-CZ culture across the app works fine, except this. So I believe the issue must lie within Kendo.
Any thoughts please? Btw, I've also tried other cultures, de-DE for example, and that didn't work either. Only en-US and sk-SK cultures remain to work. I really don't understand the difference between en-US(sk-SK) culture compared to any other. I mean, if it only worked for en-US then I would get it. But I fail to see how sk-SK is working as well. Am I doing something wrong or is this still a known issue? If that's the case, what do you please suggest I do?
Thank you.
Best regards,
Lukas
0
Viktor Tachev
Telerik team
answered on 30 Sep 2016, 01:53 PM
Hello Lukas,

Please follow the instructions from the following article for setting the culture for the application.


Also, upgrade the components to the latest release and see how it works for you. The current version is 2016.3.914. In case the issue persists please open a support ticket and send us a sample runnable project where the issue is replicated.

Regards,
Viktor Tachev
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Lukáš
Top achievements
Rank 1
answered on 01 Oct 2016, 09:03 AM
Hello Viktor,

Thank you for your answer. I updated telerik components to the version 2016.3.914 and now default operators works only for en-US. When the culture is sk-SK or cs-CZ the default operators don't work. I am glad it's not so weird anymore, but it doesn't work even more than before.
0
Viktor Tachev
Telerik team
answered on 04 Oct 2016, 01:53 PM
Hi,

Please ensure that the client- and server-side cultures match as described below and see how the behavior changes.



Regards,
Viktor Tachev
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Lukáš
Top achievements
Rank 1
answered on 06 Oct 2016, 04:49 PM

Hi,

I have created Ticket ID: 1067033 with the sample runnable project. Take a look please.

Lukas

0
Viktor Tachev
Telerik team
answered on 07 Oct 2016, 02:12 PM
Hello Lukas,

I have replied in the ticket you have submitted and suggest we continue the conversation there.  Let me know if you have additional queries.

Regards,
Viktor Tachev
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Leo
Top achievements
Rank 1
answered on 26 Jan 2017, 02:10 PM
I have the same issue with culture nl-NL  and kendo mvc 2017.1  Could you let me know if there is a fix for this?
0
Lukáš
Top achievements
Rank 1
answered on 27 Jan 2017, 09:52 AM
No it's still the same.. It's logged into Telerik system https://github.com/telerik/kendo-ui-core/issues/2308 with raised priority but still nothing...
0
Viktor Tachev
Telerik team
answered on 30 Jan 2017, 10:07 AM
Hello,

Our developers are doing their best to address the behavior as soon as possible. You can monitor the issue logged in the github repository in order to see when a fix is available.


Regards,
Viktor Tachev
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Nico
Top achievements
Rank 1
answered on 05 Apr 2017, 12:38 PM
Hello, we also have the excactly same problem. When we cahnge the culture to e.g. de-DE the custom filters wont work, only if override it on each column. 
0
Viktor Tachev
Telerik team
answered on 07 Apr 2017, 08:35 AM
Hello Nico,

I apologize for any inconvenience the issue may cause you. You can monitor its status in the link below. 



Regards,
Viktor Tachev
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Juergen
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Juergen
Top achievements
Rank 1
Lukáš
Top achievements
Rank 1
Viktor Tachev
Telerik team
Leo
Top achievements
Rank 1
Nico
Top achievements
Rank 1
Share this question
or