Hello,
Currently I'm having an issue with a Custom Filter in my Grid. I'm trying to get all our function groups from our server and make those filterable in the Grid.
However the name I want to use for filtering isn't found in the Grid schema and throwing an error.
To fill my Grid i'm using odata-v4 and Extending it with extra data. The problem is i'm trying to create the custom filter on data in the Extended object I get from odata. However when i try to apply the filter I get the error message "ReferenceError: Employee is not defined".
I've tested what happens if I try to apply the filter to a field in the base schema of the Grid's datasource and then the data is retrieved as expected.
So my question is how can I apply the filter to an attribute in the Extended object?
Kendo Grid Schema
01.schema: {02. total: function(data) {03. return data["@odata.count"];04. },05. model: {06. id: "EmployeeId",07. fields: {08. EmployeeId: { type: "number", editable: false },09. EmployerBudgetId: { type: "boolean" },10. Id: { type: "string" },11. CreatedDate: { type: "string", defaultValue: new Date().toISOString() },12. CreatedBy: { type: "string" },13. LastModifiedDate: { type: "string", defaultValue: new Date().toISOString() },14. LastModifiedBy: { type: "string" },15. Description: { type: "number" },16. StartDate: { type: "number" },17. EndDate: { type: "number" },18. }19. }20.},KendoGrid Datagrid
01.$scope.datagrid = {02. dataSource: dataSource,03. pageable: true,04. filterable: true,05. sortable: true,06. selectable: true,07. height: 800,08. toolbar: ['create', { name: 'edit', title: 'Bulk Edit', template: '<a ng-click="bulkEdit()" class="k-button k-button-icontext k-grid-edit">Bulk Edit</a>' }],09. columns: [10. { title: 'select', template: '<input class="checkbox" type="checkbox" />' },11. { field: "Employee.Email", title: "Email" },12. { field: "Employee.LocalFunctionGroup", title: "Local Function Group" },13. {14. field: 'Employee.FunctionGroup.Name', // Custom Filter (on extended data)15. title: "Global Function Group",16. filterable: {17. multi: true,18. dataSource: filterDatasource,19. dataTextField: "Name"20. },21. template: '# if (Employee.FunctionGroup != null) { # #: Employee.FunctionGroup.Name # # } #',22. },23. { field: "CurrentAmount.Amount", title: "Current Amount" },24. { command: ["edit", "destroy"], title: " ", width: "110px" },25. ],26. editable: "popup",27. };KendoFitlerSchema
01.schema: {02. model: {03. id: "Id",04. fields: {05. Id: { type: "number", editable: false },06. Name: { type: "string" },07. }08. }09.},ResponseBody odata
01.{02. "@odata.context": "https://localhost/Awvn.Admin.Api/odata/$metadata#EmployeeBudgets",03. "value": [04. {05. "Id": 4,06. "CreatedDate": "2017-03-29T08:27:07.17+02:00",07. "CreatedBy": "EmployeeBudgetsInitializer",08. "LastModifiedDate": "2017-03-29T08:27:07.17+02:00",09. "LastModifiedBy": "EmployeeBudgetsInitializer",10. "Description": null,11. "StartDate": "2000-01-01T00:00:00+01:00",12. "EndDate": "2100-01-01T00:00:00+01:00",13. "EmployeeId": 4162,14. "EmployerBudgetId": 3,15. "InitialAmount": {16. "Amount": 0,17. "Currency": "EUR"18. },19. "CurrentAmount": {20. "Amount": 0,21. "Currency": "EUR"22. },23. "Employee": {24. "Id": 4162,25. "IsDeleted": false,26. "Email": "Rick75@import.nl",27. "LocalFunctionGroup": "Automotive",28. "FunctionGroupId": 2,29. "UserId": null,30. "EmployerId": 2,31. "FunctionGroup": {32. "Id": 2,33. "Name": "Accounting / Financieel" <- The field I want to use for my filtering34. }35. }36. }37. ]38.}
Kendo UI version: "2017.1.223"
Chrome Version 56.0.2924.87