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

Asp.Net MVC Grid multiple column filters

3 Answers 308 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 25 Nov 2017, 06:01 PM

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.

 

 

3 Answers, 1 is accepted

Sort by
0
Steve
Top achievements
Rank 1
answered on 25 Nov 2017, 09:07 PM

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

 

 

0
Stefan
Telerik team
answered on 28 Nov 2017, 08:45 AM
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.
0
Steve
Top achievements
Rank 1
answered on 28 Nov 2017, 01:59 PM
OK, I am at 2017.3.1018. I will upgrade and test. Thanks.
Tags
Grid
Asked by
Steve
Top achievements
Rank 1
Answers by
Steve
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or