PDA

View Full Version : ExtJS errors after mutating a grid cell: Cannot read property 'isEntity' of undefined



rjansen
10 Feb 2015, 12:07 AM
Hello. I'm a newbie with ExtJS. Currently I'm evaluating Ext JS 5.1.0.107 by making a very simple app. The basics of the app is created by the Sencha Cmd. Now I have a screen with some basic layout and a custom grid. This grid I have made myself with a Store, Models and a RESTful Json backend. The grid is display the data and I can mutate the date by click a cell. After editing the data is PUTted as well. The response does not contains errors, but proper json. But... after doing the mutation, I get errors from Ext itself, not my custom code. When I click a row or cell again, these are the errors I get:


"Uncaught TypeError: Cannot read property 'isEntity' of undefined" in ext-all-rtl-debug.js on line 136665
The line is "if (recordIdx.isEntity) {"


"Uncaught TypeError: Cannot read property 'view' of undefined" in ext-all-rtl-debug.js on line 146012
The line is "view = pos.view || me.primaryView;"


Snippet of Main.js:


items: [{
xtype: 'grid',
selModel: 'cellmodel',
plugins: [
Ext.create('Ext.grid.plugin.RowEditing')
],
title: 'Simpsons',
store: 'User',
columns: [
{ text: 'Id', dataIndex: 'id', xtype: 'numbercolumn', format: '0'},
{ text: 'Naam', dataIndex: 'naam', editor: 'textfield' }
]
....

I would appreciate any help. Thanks.


Richard

suzuki1100nz
10 Feb 2015, 12:44 AM
Hi Richard,

Are you specifically using rtl?

rjansen
10 Feb 2015, 12:49 AM
Hi Richard,

Are you specifically using rtl?

No, this was the default when I installed the demo app with Cmd. I also tried using 'ext-all.js' (edited in bootstrap.json), but it gave the same errors.

suzuki1100nz
10 Feb 2015, 12:52 AM
Don't use rtl if you don't need it.
If you don't use it you wont get those errors.

rjansen
10 Feb 2015, 1:00 AM
I tried that by using ext-all.js. But unfortunatily I get the same errors.I only changed the entry to ext-js.all but I see a lot of 'rtl' entries in this bootstrap.json. I probably need do something else to avoid rtl. Can you tell me if that is the case and how I will do that?

suzuki1100nz
10 Feb 2015, 1:12 AM
ok I dont think you should change bootstrap.json.
Look at app.json to configure your js files.
Have a look at app.defaults.json for options your can override in app.json
app.defaults.json
is in .sencha\app directory

Look for the the js object

rjansen
10 Feb 2015, 1:22 AM
In app.json I see "path": "${ext.dir}/build/ext-all-rtl-debug.js". I can change that. I don't see/have a .sencha\app directory. Shall I change app.json and after that, how will it end up in my app? Do I need to run a Sencha Cmd command afterwards? Thanks so far for you help.

suzuki1100nz
10 Feb 2015, 1:33 AM
After editing the app.json file do a rebuild.

http://docs-origin.sencha.com/cmd/5.x/advanced_cmd/cmd_reference.html#sencha_app_build


(http://docs-origin.sencha.com/cmd/5.x/advanced_cmd/cmd_reference.html#sencha_app_build)

rjansen
10 Feb 2015, 1:35 AM
I made a new build (sencha app build) and it generates new bootstrap with ext-all-debug.js etc. No errors while building. But unfortunaly my problem still exists.

rjansen
10 Feb 2015, 2:29 AM
I solved it. The solution lies in json response. The "id" field in the json response was of the type 'string'. I changed that to integer and now ExtJS is not complaining anymore! The id property in the model is an integer and the json response should return it as an integer. But why is ExtJs not flexible enough to handle string id's as it is an integer? Or at least throw a clear message with hits to solve it.

Cheers, Richard

rjansen
10 Feb 2015, 4:27 AM
So.. after solving this problem I was immediately had to solve the next one due to the first solution. A combobox which uses the same store now had a broken css/layout. There was data in the combobox though, but it was displayed in a tranparant div without padding. The combobox is broken. Reason: because the id properties are now of the type 'int'. Weird. Final solution is that I had to remove the "type: 'int'" property in the 'fields' definition in the model.
What went wrong and why couldn't I use the 'type' property properly?
Richard