Server Fitltering Not working

2 posts, 0 answers
  1. Paul
    Paul avatar
    1 posts
    Member since:
    Sep 2011

    Posted 04 Dec 2017 Link to this post

    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");
                })
    )
    )
  2. Stefan
    Admin
    Stefan avatar
    2950 posts

    Posted 06 Dec 2017 Link to this post

    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.
Back to Top