Filter - selected type on opening

8 posts, 1 answers
  1. Emil
    Emil avatar
    46 posts
    Member since:
    Mar 2016

    Posted 31 May 2016 Link to this post

    Hello,

    Is there a way so that when I open up the filter in the grid, "Contains" will be the default in the dropdownlist? Instead of the first item in the list ?

     

    Regards,

    Emil

     

  2. Patrick
    Admin
    Patrick avatar
    237 posts

    Posted 31 May 2016 Link to this post

    Hi Emil,

    Please take a look at this Kendo UI Dojo by Progress which illustrates how to set the filter's default operator to Contains.  

    Here is how filterable.cell.operator is used in this example:
    columns: [
             {
               ...
               filterable: {
                 cell: {
                   operator: "contains"
                 }
               }
             },
             ... ]

    Hope this helps!

    Regards,
    Patrick
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Emil
    Emil avatar
    46 posts
    Member since:
    Mar 2016

    Posted 08 Jun 2016 in reply to Patrick Link to this post

    is it possible to do this in the c# razor view ? instead of jquery ?

    I tried something like that, but it didnt work, didnt give me any errors though.

     @(Html.Kendo().Grid<VaultLeitarvefur.Models.VaultNidurstodur>()
        .Name("grid")
        .Columns(columns =>
        {
            columns.Bound(p => p.Verkefni).Title(VaultLeitarvefur.Models.VaultNidurstodur.Key01).Width(150).Filterable(u => u.Cell(j => j.Operator("Contains")));

     

  4. Patrick
    Admin
    Patrick avatar
    237 posts

    Posted 08 Jun 2016 Link to this post

    Hi Emil,

    Yes, you can do the same in C# Razor.  Please take a look at the following demo "Filter Row" and select the .cshtml source at the bottom.  

    You can see the implementation being used for the ShipName column:

    .Columns(columns =>
    {
        ...
        columns.Bound(p => p.ShipName).Width(500).Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));
        ...
    })

    Also, thank you for providing your code snippet.  I believe if you lowercase "contains", it should work. 

    Hope this helps!

    Regards,
    Patrick
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  5. Emil
    Emil avatar
    46 posts
    Member since:
    Mar 2016

    Posted 09 Jun 2016 in reply to Patrick Link to this post

    I copied your verison and it actually is exactly the same as mine and doesnt work.

    I do have 

    .Filterable(f => f.Operators(m => m.ForString(n => n.IsEqualTo("Jafngilt")
                            .EndsWith("Lýkur með")
                            .IsEmpty("Er tómt")
                            .IsNotEmpty("Er Ekki tómt")
                            .IsNotEqualTo("Er ekki jafngilt")
                            .IsNotNull("Er ekki null")
                            .IsNull("Er null")
                            .StartsWith("Hefst með")
                            .Contains("Inniheldur")
                            .DoesNotContain("Inniheldur ekki")
                             )))

    later in the code, but that should affect it. I tried contains and Contains it still doesnt select that item from the dropdownlists.

    any ideas ?

    there are no errors, just selects the first one.

    Regards,

    Emil

  6. Answer
    Patrick
    Admin
    Patrick avatar
    237 posts

    Posted 09 Jun 2016 Link to this post

    Hello Emil,

    Please take a look at the attached Kendo MVC Project which illustrates how to have the contains first appear.  Be sure to include Filter mode for the grid.  In this case, it would be by row.
    .Filterable(f => f.Mode(GridFilterMode.Row))

    Regards,
    Patrick
    Telerik
     
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
     
  7. Emil
    Emil avatar
    46 posts
    Member since:
    Mar 2016

    Posted 09 Jun 2016 in reply to Patrick Link to this post

    Well done, that was what was missing. I just had .Filterable() , didnt set the mode.

     

    Thank you

    Emil

  8. Patrick
    Admin
    Patrick avatar
    237 posts

    Posted 09 Jun 2016 Link to this post

    Hello Emil,

    Glad to help and that your filter is working!

    Regards,
    Patrick
    Telerik
     
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
     
Back to Top