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

Server Fitltering Not working

1 Answer 99 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 04 Dec 2017, 10:04 AM

Hello,

I'm trying to use serverFiltering with Razor, but when I step through my code I can see that Filtering is always Null. Here's my code - can someone see what the issue may be?

@(Html.Kendo().Grid<DAL.ViewModels.Lists.AccountList>()
            .Name("kendogridvpc")
            .Columns(columns =>
            {
            columns.Bound(c => c.FirstName).Width(175);
            columns.Bound(c => c.LastName).Width(175);
            columns.Bound(c => c.Email);
            columns.Bound(c => c.Role).ClientTemplate("<i class='fa fa-shield' aria-hidden='true' title='PF: #: PFN #'></i> #: Role #").MinScreenWidth(480);
            columns.Bound(c => c.Id).Hidden();
            columns.Bound(c => c.LatestHPFormId).Hidden();
            columns.Bound(c => c.RoleId).Hidden();
            columns.Bound(c => c.isClosed).Hidden();
            columns.Bound(c => c.IsLockedOut).Hidden();
            columns.Bound(c => c.IsApproved).Hidden();
            columns.Bound(c => c.IsLatestHPFormOnline).Hidden();
            columns.Template(@<text>Hello</text>)
                    .Title("Status")
                    .MinScreenWidth(480)
                    .Width(120)
                    .ClientTemplate("# if (IsApproved) { #<span class='user-approved'><i class='fa fa-check-circle-o' aria-hidden='true' title='Account Approved'></i></span> # } else { # <span class='user-unapproved'><i class='fa fa-check-circle-o' aria-hidden='true' title='Account Not Approved'></i></span> #}# # if (HPFormHasIssues) {#<span class='user-highlight' title='Highlighted Issues'><i class='fa fa-exclamation-triangle' aria-hidden='true'></i></span>#}# # if (isClosed) {# <span class='user-highlight' title='Account Closed'><i class='fa fa-archive' aria-hidden='true'></i></span> #} else {# #if (IsLockedOut) {#<span class='user-highlight' title='Account Suspended'><i class='fa fa-lock' aria-hidden='true'></i></span> #}# #}#");
                columns.Command(command => command.Custom("Actions").HtmlAttributes(new { @class = "btn-primary" }).Click("showMenu")).Width(110);
            }
        )
        .Pageable()
        .Sortable()
        .Filterable(ftb => ftb.Mode(GridFilterMode.Menu)
            .Operators(ops => ops.ForString(str => str.Clear()
                .StartsWith("Starts with")
                .IsEqualTo("Is equal to")
                .IsNotEqualTo("Is not equal to")
                .Contains("Contains")
                .DoesNotContain("Does not contain")
        )).Enabled(true))
        .DataSource(dataSource => dataSource
            .Custom()
            .Type("aspnetmvc-ajax")
            .PageSize(10)
            .ServerPaging(true)
            .ServerSorting(true)
            .ServerFiltering(true)
            .Filter(filters => {
                filters.Add<string>(f => f.FirstName).IsNotNull();
            })
            .Schema(schema =>
            {
                schema.Data("Data");
                schema.Total("Total");
                schema.Model(model =>
                {
                    model.Id("Id");
                    model.Field("FirstName", typeof(string));
                    model.Field("LastName", typeof(string));
                    model.Field("Email", typeof(string));
                    model.Field("Role", typeof(string));
                    model.Field("RoleId", typeof(Guid));
                    model.Field("isClosed", typeof(bool));
                    model.Field("IsLockedOut", typeof(bool));
                    model.Field("IsApproved", typeof(bool));
                });
            })
            .Transport(transport =>
            {
                transport.Read(read => read.Action("Users_Read", "User").Type(HttpVerbs.Get));
                transport.ParameterMap("parameterMap");
            })
)
)

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 06 Dec 2017, 06:51 AM
Hello, Paul,

Thank you for sharing the code with us.

I can assume that the issue occurs due to how the filtering parameters are sent to the server. I noticed that a parameterMap is used, but the implementation is missing on the post.

If the server is using the ToDataSourceRequest type in the controller, please ensure that the parameters are sent in the expected format:




If the parameters are not sent in the correct format inspect the parameterMap function to check if the issue is indeed with the format or it is with the Grid not passing the correct values.

In case an additional assistance is needed, please provide a fully runnable example and I will gladly investigate further.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular 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
Paul
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or