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

Inline Grid TypeError:Cannot use 'in' operator to search for 'xxx' in null

9 Answers 321 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Merve
Top achievements
Rank 1
Veteran
Merve asked on 28 Aug 2020, 06:59 AM

My combobox

01.function userNameEditor(container, options) {
02.    debugger;
03.    var gridDataSource = new kendo.data.DataSource({
04.        transport: {
05.            read: {
06.                url: '../Warehouse/SearchUser',
07.                dataType: "json"
08.            },
09.            success: function(e) {
10.                debugger;
11.            },
12.            error: function (e) {
13.                debugger;
14.            }
15.        }
16.    });
17.        var cmb=$('<input name="' + options.field + '"/>')
18.        .appendTo(container)
19.        .kendoComboBox({
20.            autoBind: false,
21.            dataTextField: "UserFullName",
22.            dataValueField: "Id",
23.            filter: "contains",
24.            minLength: 3,
25.            dataSource: gridDataSource,
26.            filtering: function (e) {
27.                
28.                var filter = e.filter;
29.                gridDataSource.read({ userSearchText: filter.value });
30.                //dataSource.filter({ userSearchText: filter.value });
31.            },
32.            dataBound: function (e) {
33.                debugger;
34.                var equipmentData = e.sender.dataSource.data();
35. 
36. 
37.                        $.each(equipmentData, function (index, selectedEquipmentData) {
38.                                var dataItem = e.sender.dataSource.at(index);
39. 
40.                        });
41.            },
42.            select: function(e) {
43.                debugger;
44.                this.refresh();
45.            },
46.            complete: function(e) {
47.                debugger;
48.            },
49.            error: function(e) {
50.                debugger;
51.            }
52.        }).data('kendoComboBox');
53.    cmb.refresh();
54.   
69.};

 

I have one inline grid my grid have one column user combobox.I click update  see error "Uncaught TypeError: Cannot use 'in' operator to search for 'RelId' in null" but I cant understand can you help me little?

 

My Grid

01.var grid = new BaseGrid('grdWarehouse_OnWarehouseUserRelation');
02.   grid._batch = false;
03.   grid._dataSourceAutoSync = false;
04.   grid._autoBind = false;
05.   grid._toolbar = ['create'/*, 'save', 'cancel'*/];
06. 
07.   grid._editable = {
08.       mode: "inline",
09.       create: true,
10.       update: true,
11.       destroy: true,
12. 
13.   };
14. 
15.   grid._schemaMethod = {
16.       model: {
17.           id: 'RelId',
18.           fields: {
19.               RelId: { editable: false, type: "string" },
20.               User: { defaultValue: { Id: '', UserFullName: '' } },
21.           }
22.       }
23.   };
24. 
25.   grid._columns.push(grid.GridColumn('RelId', null, '200px', null, null, null, null, null, null, null, true));
26.   grid._columns.push(grid.GridColumn('User', 'User', '200px', null,"#=User.UserFullName#", null, null, null, null, null, null, null, null, null, userNameEditor));
27.   grid._columns.push(grid.GridColumn(null, ' ', '200px', { style: 'text-align:right' }, null, null, null, null, null, null, null, null, null, ['edit', 'destroy']));
28. 
29.   grid._cancelMethod = function (e) {
30.       var uid = $("#grdWarehouse_OnWarehouseUserRelation").data("kendoGrid").dataItem($(e.container).closest("tr")).uid
31.       dataSource = $("#grdWarehouse_OnWarehouseUserRelation").data("kendoGrid").dataSource
32.       var item = dataSource.getByUid(uid);
33.       dataSource.cancelChanges(item);
34.   };
35. 
36.   grid._removeMethod = function (e) {
37.       debugger;
38. 
39.       DeleteWarehouseUserRelation(e.model.Id);
40.       e.model.IsActive = false;
41.       e.preventDefault();
42.       var uid = e.model.uid
43.       dataSource = $("#grdWarehouse_OnWarehouseUserRelation").data("kendoGrid").dataSource
44.       var item = dataSource.getByUid(uid);
45. 
46.       dataSource.cancelChanges(item);
47. 
48. 
49.       KendoData('grdWarehouse_OnWarehouseUserRelation').refresh();
50.   };
51. 
52.   grid._updateMethod = function (e) {
53. 
54.       debugger;
55.   };
56.   grid._createMethod = function (item) {
57. 
58.       debugger;
59.       var error = SameWarehouseUserReleationError();
60. 
61.       if (error == true) {
62.           CreateWarehouseUserReleation(item.data.User.Id);
63.       }
64. 
65. 
66.       KendoData('grdWarehouse_OnWarehouseUserRelation').refresh();
67.   };
68.   grid._dataBoundMethod = function (e) {
69. 
70.       $("#grdWarehouse_OnWarehouseUserRelation tbody tr .k-grid-edit").each(function () {
71. 
72.           var currentDataItem = $("#grdWarehouse_OnWarehouseUserRelation").data("kendoGrid").dataItem($(this).closest("tr"));
73. 
74.           $(this).remove();
75. 
76.       });
77. 
78.       e.sender.items().each(function () {
79.           var dataItem = e.sender.dataItem(this);
80.           kendo.bind(this, dataItem);
81.       });
82.   };
83. 
84.   grid.GetGrid();

9 Answers, 1 is accepted

Sort by
0
Alex Hajigeorgieva
Telerik team
answered on 31 Aug 2020, 02:46 PM

Hello, Merve,

Thank you very much for the provided code snippets.

I attempted to reproduce the error with the exact same editor combobox code (field names are different) to no avail:

https://dojo.telerik.com/@bubblemaster/IYekeYoc

Can you copy and paste the example in your environment and see if the error will reproduce with your current scripts. If so, which is the jQuery version that you are using?

https://docs.telerik.com/kendo-ui/intro/supporting/jquery-support

Can you share the combobox read response that you currently have?

Also, it is recommended not to use the success and error data source functions:

https://docs.telerik.com/kendo-ui/api/javascript/data/datasource/configuration/transport.read

Look forward to hearing back from you.

Kind Regards,
Alex Hajigeorgieva
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Merve
Top achievements
Rank 1
Veteran
answered on 31 Aug 2020, 05:26 PM

https://dojo.telerik.com/@bubblemaster/IYekeYoc

Hi alex!

I try this link.but still i get the same error.I try somethink like this but error same.   ;(

1.grid._columns.push(grid.GridColumn('Id', 'User', '200px', null, null, null, null, null, null, null, null, null, null, null, userNameEditor));
grid._schemaMethod = {
    model: {
        id: 'Id',
        //fields: {
        //    //Id:{ editable: true, nullable: true },     
        //    UserFullName: { validation: { required: true } },
        //}
    },
0
Merve
Top achievements
Rank 1
Veteran
answered on 01 Sep 2020, 07:59 AM

 ı add  schema method data properties in my grid.See the error and add parametermap and my error change I take "VM4765:3 Uncaught SyntaxError: Unexpected number" error .But I cant understand what is this error :(

My grid And I attach  my error picture 

01.grid._schemaMethod = {
02.    model: {
03.        id: 'Id',
04.        fields: {
05.            Id: { editable: false, type: "number" },
06.            User: { defaultValue: { Id: '', UserFullName: '' } },
07.        }
08.    },
09.    data: function (response) {
10.        debugger;
11.        if (response.Acknowledge == false)
12.            toastr.error(response.error);
13.        else {
14.            if (response.Data == undefined)
15.                return response;
16.            else
17.                return response.Data;
18.        }
19.    },
20.};
21. 
22.grid._parameterMap = function (data, type) {
23.    debugger;
24.    if (type !== "read" && data.models)
25.        return { models: kendo.stringify(data.models) };
26.    //var parameters = {
27.    //    UserFullName: data.User.UserFullName,
28.    //    Id:data.User.Id
29.    //}
30. 
31.    //return kendo.data.transports["odata"].parameterMap(parameters, type);
32.};
33.grid._columns.push(grid.GridColumn('User', 'User', '200px', null, "#=User.UserFullName#", null, null, null, null, null, null, null, null, null, userNameEditor));
34.grid._columns.push(grid.GridColumn(null, ' ', '200px', { style: 'text-align:right' }, null, null, null, null, null, null, null, null, null, ['edit', 'destroy']));

 

0
Merve
Top achievements
Rank 1
Veteran
answered on 01 Sep 2020, 10:41 AM
Hi Telerik People mt project we use BaseGrid and gice parmeter to grid and ı try to that link and write that code and build my project work ! I guess my basegrid have problem with this thanks everthink.Especially thanks to you, alex!
0
Merve
Top achievements
Rank 1
Veteran
answered on 01 Sep 2020, 02:24 PM

I give my grid datasource like this 

01.dataSource = new kendo.data.DataSource({
02.        batch: false,
03.        schema: {
04.            model: {
05.                id: "Id",
06.                fields: {
07.                    Id: { editable: false, nullable: true },
08.                    User: { defaultValue: { Id: '', UserFullName: '' } },
09.                }
10.            }
11.        },
12.        transport: {
13.            create: function (e) {debugger; UserRelationCreate()}
14. 
15.        }
16.    });

 

And I add transport my datasource and ı take same error  :( 

0
Merve
Top achievements
Rank 1
Veteran
answered on 01 Sep 2020, 03:25 PM
And this my error
0
Alex Hajigeorgieva
Telerik team
answered on 02 Sep 2020, 01:27 PM

Hi, Merve,

I noticed that the version used in the screenshots is 5 years old from 2015.3.930. So I updated the Dojo to use that version instead but the error is still not reproducible:

https://dojo.telerik.com/IHipexUv

If you like, you can provide some mock data and we can build the same grid definition as you have in your project and see if it has anything to do with the model and the data.

Until we can see the error or have a way of reproducing it, unfortunately, there is little we can do.

Kind Regards,
Alex Hajigeorgieva
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Merve
Top achievements
Rank 1
Veteran
answered on 03 Sep 2020, 05:46 AM
I am not think my old version reason the error because that link work my project.I add my controller return for my combobox And I add my combobox 

01.function userNameEditor(container, options) {
02.    debugger;
03.    var gridDataSource = new kendo.data.DataSource({
04.        transport: {
05.            read: {
06.                url: '../Warehouse/SearchUser',
07.                dataType: "json"
08.            
09.        }
10.    });
11.    var cmb = $('<input name="' + options.field + '"/>')
12.        .appendTo(container)
13.        .kendoComboBox({
14.            autoBind: false,
15.            dataTextField: "UserFullName",
16.            dataValueField: "Id",
17.            filter: "contains",
18.            minLength: 3,
19.            dataSource: gridDataSource,
20.            filtering: function (e) {
21. 
22.                var filter = e.filter;
23.                gridDataSource.read({ userSearchText: filter.value });
24.            },
25.            dataBound: function (e) {
26. 
27.                var equipmentData = e.sender.dataSource.data();
28. 
29. 
30.                $.each(equipmentData, function (index, selectedEquipmentData) {
31.                    var dataItem = e.sender.dataSource.at(index);
32. 
33.                });
34.            },
35.            select: function (e) {
36. 
37.                this.refresh();
38.            },
39.            complete: function (e) {
40. 
41.            },
42.            error: function (e) {
43. 
44.            }
45.        }).data('kendoComboBox');
46.    cmb.refresh();
47. 
48.};
0
Eyup
Telerik team
answered on 04 Sep 2020, 09:43 PM

Hello Merve,

 

I am afraid it is pretty difficult to pinpoint the reason of the issue without first reproducing it.

In order to further assist you with this case, we will need a runnable sample which demonstrates the problem. Could you modify one of the dojos provided by Alex and send it to us for further investigation?

Alternatively, you can open a formal support ticket where you can send us an isolated runnable version of your project so we can reproduce the issue locally.

This will allow us to provide more accurate and precise suggestions.

 

Regards,
Eyup
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive , special prizes and more, for FREE?! Register now for DevReach 2.0(20).

Tags
Grid
Asked by
Merve
Top achievements
Rank 1
Veteran
Answers by
Alex Hajigeorgieva
Telerik team
Merve
Top achievements
Rank 1
Veteran
Eyup
Telerik team
Share this question
or