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

Filter Menu Customization Error

3 Answers 68 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gaetano
Top achievements
Rank 1
Gaetano asked on 09 Oct 2013, 10:26 AM
Hi guys,
I'm having some issues trying to customize a filter (as a dropdownlist ) in a grid.
The result is that if I use "is equal to", the result is always nothing... (no errors, just no records)
while if I use "contains" or  "starts with" I get an error like "Object 1 has no method 'toLowerCase'" (that goes deep into kendo's and jquery's js)

here my code

column definition:
{
                    field: "Role",
                    title: "ruolo",
                    template : "<span>${Role.Name}</span>",
                    filterable: {
                        ui: RoleFilter,
                        extra: false
                    },
                    editor: function (container, object) {
                        SetRoleSelect(container, object);
                    }
                },
 
dataSource definition
fields: {
                        prop1 : {type:"string"}
                        Role: {
                            Id: { type: "int", editable: false },
                            Name: { type: "string", editable: true, validation: { required: true } },
                            Descrizione: { type: "string", editable: true, validation: { required: false } },
                            Visible: { type: "boolean", editable: true },
                            Rango: { type: "number", editable: true, validation: { required: true, min: 0 } }
}
and my function
RoleFilter: function (element) {
        element.kendoDropDownList({
            dataTextField: "Name",
            dataValueField: "Id",
            dataSource: {
                transport: {
                    read: {
                        url: "my url returning a list of Role object",
                        cache: true
                    }
                }
            },
            optionLabel: "Select a Role"
        });
    }
My guess is that there's a kind of mismatch between the object inside the filter and the in the grid's datasource...
but objects are actually the same!

Where I am doing wrong? thanks!
Fabio

3 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 09 Oct 2013, 12:37 PM
Hello Fabio,


In general, filtering, sorting, grouping etc. is not supported for columns of complex object types. A possible custom workaround would be to define the field on which the filtering will be performed.  Here is a JS Bin example with a sample implementation. Note the filterable configuration
E.g.
filterable: {
    extra: false,
    ui: CategoryFilter,
    field:"Category.CategoryName"
}

element.kendoDropDownList({
   autoBind: false,
   dataTextField: "CategoryName",
   dataValueField: "CategoryName"

Please note that this scenario is generally not supported and may cause some issues, for example when the column contains null values.

I wish you a great day!

Regards,
Dimiter Madjarov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Gaetano
Top achievements
Rank 1
answered on 10 Oct 2013, 08:32 AM
Hi Dimiter,
this workaround is not working in my case...
do you plan to correct this behavior in future releases?

and just to understand, which is the behavior in this scenario :

field: "Role",
title: "ruolo",
template : "<span>${Role.Nome}</span>",
filterable: {
    ui: MyNamespace.RoleFilter,
    extra: false,
    field: "Role.Nome"
},
editor: function (container, object) {
    MyNamespace.SetRoleSelect(container, object);
}
Am I Allowed to specify field property both for binding and for filter ? if not which is the valid one? 
thanks
Fabio

0
Dimiter Madjarov
Telerik team
answered on 10 Oct 2013, 09:09 AM
Hi Fabio,


At the moment we are not planning to support this feature. The DataSource is designed to support operations only over a flat data structures and just display nested properties via templates.

In the scenario from the sample code, the filtering will be performed over the Name property of the Role object i.e. the same as in the provided JS Bin example.

 

Regards,
Dimiter Madjarov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Gaetano
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Gaetano
Top achievements
Rank 1
Share this question
or