Asp.Net MVC Grid multiple column filters

4 posts, 0 answers
  1. Steve
    Steve avatar
    9 posts
    Member since:
    Feb 2015

    Posted 25 Nov Link to this post

    I am unable to get my grid to filter on more than 1 column. When I try to add the 2nd filter I get a 500 error because it seems Kendo is trying to make a call to my MVC action without any parameters. I'm getting this behavior on 2 different grid and dataources.

    Grid (shortened):

    @(Html.Kendo().Grid<FooItemViewModel>()

        .Name("FooGrid")
        .Columns(column =>
        {
            column.Bound(p => p.FooTypeCode).Title("Type").Width(22);
            column.Bound(p => p.FooCode).Title("Foo Code").Width(40);
            column.Bound(p => p.FooDesc).Title("Foo Description").Width(260);
            column.Bound(p => p.ReportCode).Title("Report").Width(20);
        })
        .Filterable()
        .Sortable()
        .Pageable(builder => builder.PageSizes(new[] { 10, 25, 100 }))
        .DataSource(dataSource => dataSource
            .Ajax()
            .PageSize(25)
            .Model(m =>
            {
                m.Id(s => s.FooID);
                m.Field(s => s.FooID).Editable(false);
            })
            .Read(read => read.Action("Read", "Foo"))
            .Create(create => create.Action("Create", "Foo"))
            .Update(update => update.Action("Update", "Foo"))
            .Destroy(update => update.Action("Delete", "Foo"))
            .Events(events => events.Error("onDataSourceError"))
        ))

    Controller:

        public JsonResult Read([DataSourceRequest] DataSourceRequest request)
            {
                var Foos = _db.Foos.Project().To<FooItemViewModel>();
                DataSourceResult response = Foos.ToDataSourceResult(request);
                return Json(response, JsonRequestBehavior.AllowGet);
            }

    I have tried adding .ServerOperation(true), but that does not work. When the grid first loads I hit the Read action with empty datasourcerequest as expected. When I add a filter I also hit the server read action with a datasourcerequest and the expected column filter passed in. When I select a 2nd column filter and click "Filter" I get the 500 error in the console because it appears it tries to just call \Foo\Read without any parameters.

    I see a "serverFiltering: true" in jquery version, but no equivalent in the MVC wrappers. Any help appreciated.

     

     

  2. Steve
    Steve avatar
    9 posts
    Member since:
    Feb 2015

    Posted 25 Nov Link to this post

    Actually when I look at the 2 POSTs they are similar:

    Working request:  sort=&page=1&pageSize=25&group=&filter=FooCode~contains~'10.1'

    Request URL: http://localhost:61556/Foo/Read

    Request Method: POST
    Status Code: 200 OK
    Remote Address: [::1]:61556
    Referrer Policy: no-referrer-when-downgrade

    Failing: sort=&page=1&pageSize=25&group=&filter=FooCode~contains~'10.1'~and~FooDesc~contains~'hunt'

    Request URL: http://localhost:61556/Foo/Read
    Request Method: POST
    Status Code: 500 Internal Server Error
    Remote Address: [::1]:61556
    Referrer Policy: no-referrer-when-downgrade

     

     

  3. Stefan
    Admin
    Stefan avatar
    1389 posts

    Posted 28 Nov Link to this post

    Hello, Steve,

    Could you confirm if the used version is the one selected in the forum "2017.3 1026", as we had the same known issue which is already fixed in the latest version "2017.3 1026".

    Please ensure that the application is using the latest version, and if the issue still occurs, provide a fully runnable example, so we can investigate further.

    As for the server filtering - in the MVC version of the widgets all operations are set server side by default. In order to disable them set the dataSource server operations to false:

    .DataSource(source => {
        .ServerFiltering(false);
        //.......


    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.
  4. Steve
    Steve avatar
    9 posts
    Member since:
    Feb 2015

    Posted 28 Nov in reply to Stefan Link to this post

    OK, I am at 2017.3.1018. I will upgrade and test. Thanks.
Back to Top