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

Filter on Date-Field acts like String-Filter

1 Answer 53 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steffen
Top achievements
Rank 1
Steffen asked on 04 Aug 2015, 08:05 AM

hi,

 

in my AngularJS app I've bound the Kendo Grid to a SharePoint 2010 REST Webservice and defined it as follows:

 

001.$scope.mainGridOptions = {
002. 
003.        filterable: {
004.            extra: false,
005.            messages: {
006.                info: "Datensätze filtern:",
007.                filter: "Filtern",
008.                clear: "Löschen",
009.                and: "und",
010.                or: "oder"
011.            },
012.            operators: {
013.                string: {
014.                    contains: "beinhaltet",
015.                    eq: "ist gleich",
016.                    neq: "ist nicht gleich"
017.                },
018.                date: {
019.                    eq: "ist gleich",
020.                    gt: "nach",
021.                    lt: "vor"
022.                },
023.                number: {
024.                    eq: "ist gleich",
025.                    gt: "größer als",
026.                    lt: "kleiner als"
027.                },
028.            }
029.        },
030.        sortable: true,
031.        scrollable: false,
032.        pageable: {
033.            previousNext: true,
034.            numeric: true,
035.            refresh: true,
036.            pageSizes: [5, 10, 25],
037.            messages: {
038.                display: "{0} - {1} von insgesamt {2}",
039.                empty: "Keine Daten",
040.                itemsPerPage: "Datensätze pro Seite",
041.                refresh: "Neu laden"
042.            }
043.        },
044.        dataSource: new kendo.data.DataSource({
045.            type: "odata",
046.            transport: {
047.                read: {
048.                    url: $scope.filterParams.url,
049.                    dataType: "json"
050.                }
051.            },
052.            sort: ({ field: "Erstellt", dir: "desc" }),
053.            pageSize: 5,
054.            resizable: true,
055.            serverSorting: true,
056.            serverFiltering: true,
057.            serverPaging: true,
058.            schema: {
059.                model: {
060.                    fields: {                       
061.                        Erstellt: { type: "date" },
062.                        ErstelltVon: {
063.                            Name: {
064.                                type: "string"
065.                            }
066.                        },
067.                        Geändert: { type: "date" },
068.                        GeändertVon: {
069.                            Name: {
070.                                type: "string"
071.                            }
072.                        }
073.                    }
074.                }
075.            }
076.        }),
077.        columns: [                   
078.                    {
079.                        field: "ErstelltVon.Name",
080.                        title: "Erstellt von",
081.                        width: "130px"
082. 
083.                    },
084.                    {
085.                        field: "Erstellt",
086.                        title: "Erstellt am",
087.                        width: "130px",
088.                        type: "date",
089.                        format: "{0:dd.MM.yyyy HH:mm:ss}",
090.                        parseFormats: ["dd.MM.yyyy"],
091.                        template: '#= kendo.toString(new Date(data.Erstellt.getTime() + data.Erstellt.getTimezoneOffset()*60000), "dd.MM.yyyy HH:mm:ss tt") #'//Timezone correction
092.                    },
093.                    {
094.                        field: '["GeändertVon"].Name',
095.                        title: "Geändert von",
096.                        width: "130px"
097. 
098.                    },
099.                    {
100.                        field: '["Geändert"]',
101.                        title: "Geändert am",
102.                        width: "130px",
103.                        type: "date",
104.                        format: "{0:dd.MM.yyyy HH:mm:ss}",
105.                        parseFormats: ["dd.MM.yyyy"],
106.                        template: '#= kendo.toString(new Date(data.Geändert.getTime() + data.Geändert.getTimezoneOffset()*60000), "dd.MM.yyyy HH:mm:ss tt") #' //Timezone correction
107.                    }
108. 
109.        ]
110.    }

 

this is a part of the data from the REST Service:

 

1.<d:Geändert m:type="Edm.DateTime">2015-08-04T09:31:53</d:Geändert>
2.<d:Erstellt m:type="Edm.DateTime">2015-07-28T11:06:19</d:Erstellt>

 

 

all of the data is displayed correctly.

the problem is the filter menu.

On the "Erstellt" field it displays the options for a date-type (eq, lt, gt) which i've defined.

On the "Geändert" field it displays the options i defined for string-types, although i've declared it as a date field.

 

Thank you!!

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 06 Aug 2015, 08:17 AM

Hello Steffen,

 

The umlaut character (ä) should be encoded properly so there is no need to place the field name in [] in the columns. filed definition. When the field name is wrapped in [] it is treated as a string, so the filter menu options for string type will be shown. 

 

Regards,
Boyan Dimitrov
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
Steffen
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Share this question
or