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

Group breaks Filtering

5 Answers 162 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 07 Dec 2017, 02:55 PM

if I add:

.Group(g => {
                g.Add(c => c.DistrictName);
                g.Add(c => c.SchoolName);
                })

to my datasource:

.DataSource(ds => ds
            .Ajax()
            .ServerOperation(false)
            .Read(read => read.Action("RetrieveReqStatusReport", "ReportSupport", new { orgId = ViewBag.OrgSelection.Id, personId = ViewBag.PersonId, yearId = ViewBag.YearSelection.Id }))
            .PageSize(50)
            .Group(g => {
                g.Add(c => c.DistrictName);
                g.Add(c => c.SchoolName);
                })
        )

then

 function filterMenuInit(e) {
        if (e.field == "DueDate") return;
        var filterMultiCheck = this.thead.find("[data-field=" + e.field + "]").data("kendoFilterMultiCheck")
        filterMultiCheck.container.empty();
        filterMultiCheck.checkSource.sort({ field: e.field, dir: "asc" });

        filterMultiCheck.checkSource.data(filterMultiCheck.checkSource.view().toJSON());
        filterMultiCheck.createCheckBoxes();
    }

generates the following error when I try to filter:

Uncaught ReferenceError: DistrictName is not defined
    at eval (eval at compile (kendo.all.min.js:25), <anonymous>:3:209)
    at Object.render (kendo.all.min.js:25)
    at Object.d [as render] (jquery.min.js:2)
    at init.createCheckBoxes (kendo.all.min.js:45)
    at init.filterMenuInit (1:371)
    at init.trigger (kendo.all.min.js:25)
    at init.c (kendo.all.min.js:53)
    at init.trigger (kendo.all.min.js:25)
    at init._init (kendo.all.min.js:45)
    at init._click (kendo.all.min.js:45)

if I remove it, multi-filter works fine.

TIA for the insight into what I'm failing to understand.

5 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 11 Dec 2017, 09:20 AM
Hello, Mark,

Thank you for the provided details.

After inspecting it I noticed that the issue occurs because the dataSource.view() returns the data in a different format if the Grid is grouped.

https://docs.telerik.com/kendo-ui/api/javascript/data/datasource#methods-view

In this scenario, I can suggest using the data method instead of the view() method.

filterMultiCheck.checkSource.data(filterMultiCheck.checkSource.data().toJSON());

I hope this is helpful.

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
Accepted
Rakesh
Top achievements
Rank 1
answered on 11 Dec 2017, 08:34 PM

Stefan..

 

After grouping, I wasnt able to get hold of filterMultiCheck object through  either of the below

this.thead.find(".k-filterable").data("kendoFilterMultiCheck");

this.thead.find("[data-field=" + e.field + "]").data("kendoFilterMultiCheck");

 

Should I be using some other selector if the data is grouped?

 

 

0
Mark
Top achievements
Rank 1
answered on 12 Dec 2017, 07:06 PM
thanks!
0
Stefan
Telerik team
answered on 13 Dec 2017, 09:33 AM
Hello, Rakesh,

The example is still working on my end after grouping the Grid as well.

Please check the following example demonstrating this:

http://dojo.telerik.com/omEgOW

Please let me know if I missed an important detail.

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
SEAN
Top achievements
Rank 1
answered on 07 Oct 2018, 11:37 PM
I tried using the data() method as you suggested but I was also using a filter to remove some values from the results so I needed to use the view() method. I managed to get it working by using the view() method, which returns the wrong format, but I was able to get to the right format as follows:
var viewArray = new kendo.data.ObservableArray(filterMultiCheck.checkSource.view()[0].items); // for grouped grids, wrap the view results in an ObservableArray
filterMultiCheck.checkSource.data(viewArray.toJSON());
Tags
Grid
Asked by
Mark
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Rakesh
Top achievements
Rank 1
Mark
Top achievements
Rank 1
SEAN
Top achievements
Rank 1
Share this question
or