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

Defining Grid Filtering Operators issue

2 Answers 1042 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 24 Feb 2017, 09:23 PM

Hey there guys, I've spent a good amount of time looking through other people's issues for this problem and haven't found it addressed yet.

Basically the problem I'm experiencing is trying to create an extension method to HtmlHelper (which works fine), but for some reason setting up corrected operators on filterable is causing issues. Here the code I am trying to use:

public static GridBuilder<T> ExtensionGrid<T>(this IHtmlHelper<dynamic> helper, string name)
            where T : class
        {
            return helper.Kendo().Grid<T>()
                .Name(name)
                .Filterable(filterable => filterable
                    .Extra(false)
                    .Operators(operators => operators
                        .ForString(str => str
                            .Clear()
                            .Contains("Contains")
                            .DoesNotContain("Does not contain")
                            .StartsWith("Starts with")
                            .EndsWith("Ends with")
                            .IsEqualTo("Is equal to")
                            .IsNotEqualTo("Is not equal to ")   // <== trailing space is intentional.
                        )
                    )
                )
                .Pageable(pager => pager
                    .ButtonCount(5)
                    .PageSizes(new int[] { 5, 10, 20, 50, 100, 150, 200 })
                    .Input(true)
                    .Refresh(true)
                )
                .Sortable(sortable => sortable
                    .Enabled(true)
                    .AllowUnsort(false)
                )
                .Events(events =>
                {
                    events.FilterMenuInit("trapKendoGridFilterEnterKey");
                });
        }

I can see the UI responding to the Extra(false) piece, but not to the ForString() piece (still just seeing the default string operators). I also see the same behavior when I apply it directly to a grid like this:

@(Html.Kendo().Grid<Role>()
            .Name("RoleGrid")
            .Columns(columns =>
            {
                columns.Bound(c => c.RoleId)
                    .Hidden(true);
                columns.Bound(c => c.RoleCode);
                columns.Bound(c => c.RoleName);
                columns.Bound(c => c.RoleDescription);
                columns.Bound(c => c.RoleDisplayOrder);
            })
            .Filterable(filterable => filterable
                .Extra(false)
                .Operators(operators => operators
                    .ForString(str => str
                        .Clear()
                        .Contains("Contains")
                        .DoesNotContain("Does not contain")
                        .StartsWith("Starts with")
                        .EndsWith("Ends with")
                        .IsEqualTo("Is equal to")
                        .IsNotEqualTo("Is not equal to ")
                    )
                )
            )
            .Scrollable()
            .Selectable()
            .Sortable()
            .Pageable(pageable => pageable
                .ButtonCount(5)
                .PageSizes(new int[] { 5, 10, 20, 50, 100, 150, 200 })
                .Input(true)
                .Refresh(true)
            )
            .DataSource(dataSource => dataSource
                .Ajax()
                .Model(model =>
                {
                    model.Id(m => m.RoleId);
                    model.Field(m => m.RoleId).Editable(false);
                })
                .Events(events => events
                    .Error("ajaxErrorHandlerForGrid('RoleGrid')")
                )
                .Read(read => read.Action("Role_Read", "Shared"))
            )
        )

 

The only time I do see it working is with a row level filter such as this:

@(Html.Kendo().Grid<Role>()
            .Name("RoleGrid")
            .Columns(columns =>
            {
                columns.Bound(c => c.RoleId)
                    .Hidden(true);
                columns.Bound(c => c.RoleCode)
                    .Filterable(f => f.Extra(false).Operators(o => o.ForString(str => str.Clear().Contains("Contains"))));
                columns.Bound(c => c.RoleName);
                columns.Bound(c => c.RoleDescription);
                columns.Bound(c => c.RoleDisplayOrder);
            })
            .Filterable(filterable => filterable
                .Extra(false)
                .Operators(operators => operators
                    .ForString(str => str
                        .Clear()
                        .Contains("Contains")
                        .DoesNotContain("Does not contain")
                        .StartsWith("Starts with")
                        .EndsWith("Ends with")
                        .IsEqualTo("Is equal to")
                        .IsNotEqualTo("Is not equal to ")
                    )
                )
            )
            .Scrollable()
            .Selectable()
            .Sortable()
            .Pageable(pageable => pageable
                .ButtonCount(5)
                .PageSizes(new int[] { 5, 10, 20, 50, 100, 150, 200 })
                .Input(true)
                .Refresh(true)
            )
            .DataSource(dataSource => dataSource
                .Ajax()
                .Model(model =>
                {
                    model.Id(m => m.RoleId);
                    model.Field(m => m.RoleId).Editable(false);
                })
                .Events(events => events
                    .Error("ajaxErrorHandlerForGrid('RoleGrid')")
                )
                .Read(read => read.Action("Role_Read", "Shared"))
            )
        )

 

I have tried setting the GridFilterMode to menu, but that didn't cause any change. And I'm using the latest release of Telerik.UI.for.AspNet.Core (2017.1.118), the project type is .NET Core with .NET Framework, and it is using similar code to a .NET Framework project that currently works fine. Is this functionality that is no longer supported or is there a new way to implement it that I am missing?

Thanks for the help.

2 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 28 Feb 2017, 11:06 PM
Hi Mike,

This seems to be a problem with the Core wrappers and the same issue can be observed in the following demo:
I will log this as a bug, so that our developers can take a look at it and provide a fix in the upcoming releases.

Please excuse us for any inconvenience caused by this.


Kind Regards,
Konstantin Dikov
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
Konstantin Dikov
Telerik team
answered on 06 Apr 2017, 11:20 AM
Hi,

Here is a link to the public item, where the status of the issue could be followed:

Best Regards,
Konstantin Dikov
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
Mike
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or