Custom filter not working when culture is changed

15 posts, 0 answers
  1. Juergen
    Juergen avatar
    5 posts
    Member since:
    Apr 2014

    Posted 02 Jul 2014 Link to this post

    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

  2. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 04 Jul 2014 Link to this post

    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.

     
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Juergen
    Juergen avatar
    5 posts
    Member since:
    Apr 2014

    Posted 04 Jul 2014 Link to this post

    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
  5. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 07 Jul 2014 Link to this post

    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.

     
  6. Juergen
    Juergen avatar
    5 posts
    Member since:
    Apr 2014

    Posted 07 Jul 2014 Link to this post

    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
  7. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 09 Jul 2014 Link to this post

    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.

     
  8. Juergen
    Juergen avatar
    5 posts
    Member since:
    Apr 2014

    Posted 09 Jul 2014 in reply to Petur Subev Link to this post

    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
  9. Juergen
    Juergen avatar
    5 posts
    Member since:
    Apr 2014

    Posted 09 Jul 2014 in reply to Juergen Link to this post

    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
  10. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 10 Jul 2014 Link to this post

    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.

     
  11. Lukáš
    Lukáš avatar
    3 posts
    Member since:
    Mar 2016

    Posted 28 Sep Link to this post

    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
  12. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 30 Sep Link to this post

    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
  13. Lukáš
    Lukáš avatar
    3 posts
    Member since:
    Mar 2016

    Posted 01 Oct in reply to Viktor Tachev Link to this post

    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.
  14. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 04 Oct Link to this post

    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
  15. Lukáš
    Lukáš avatar
    3 posts
    Member since:
    Mar 2016

    Posted 06 Oct in reply to Viktor Tachev Link to this post

    Hi,

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

    Lukas

  16. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 07 Oct Link to this post

    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
Back to Top
UI for ASP.NET MVC is VS 2017 Ready