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

Filter - selected type on opening

7 Answers 72 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Emil
Top achievements
Rank 1
Emil asked on 31 May 2016, 02:36 PM

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

 

7 Answers, 1 is accepted

Sort by
0
Patrick | Technical Support Engineer, Senior
Telerik team
answered on 31 May 2016, 08:05 PM
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!
 
0
Emil
Top achievements
Rank 1
answered on 08 Jun 2016, 01:55 PM

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")));

 

0
Patrick | Technical Support Engineer, Senior
Telerik team
answered on 08 Jun 2016, 03:54 PM
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!
 
0
Emil
Top achievements
Rank 1
answered on 09 Jun 2016, 08:38 AM

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

0
Accepted
Patrick | Technical Support Engineer, Senior
Telerik team
answered on 09 Jun 2016, 02:49 PM
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.
 
0
Emil
Top achievements
Rank 1
answered on 09 Jun 2016, 02:57 PM

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

 

Thank you

Emil

0
Patrick | Technical Support Engineer, Senior
Telerik team
answered on 09 Jun 2016, 08:39 PM
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.
 
Tags
Grid
Asked by
Emil
Top achievements
Rank 1
Answers by
Patrick | Technical Support Engineer, Senior
Telerik team
Emil
Top achievements
Rank 1
Share this question
or