-
23 Sep 2007 4:17 AM #1
[1.1.1] JsonReader: mapping to undefined element
[1.1.1] JsonReader: mapping to undefined element
http://extjs.com/forum/showthread.php?p=45310#post45310
This issue was touched on a couple of months ago, but never made it to 1.1.1 . Though it was suggested in the thread to submit a bug report, I couldn't find one in my search.
What happens is this: if you have a record field mapped to another field (deep down, not on the second level - e.g. mapping:"country.city.street" with country.city undefined), which doesn't exist in the current record's data.. then the whole reading process stops, and thus data loading stops, without any data being loaded.
This shouldn't happen. Instead, the field's value should get the defaultValue.
Animal - already provided a solution, but since this seems to be not an "personal/individual enhancement" it seems logical not to have it as a "hack" (overriding general release functions).
-
23 Sep 2007 6:28 AM #2
According to the definition of bug in http://extjs.com/forum/showthread.php?t=8887:
this is not a bug. The intended behavior is to process JSON containing all fields received from the server and that is what JsonReader does flawlessly.What's a bug?
A software bug is an error, flaw, mistake, failure, or fault in a computer program that prevents it from behaving as intended (adapted from this Wikipedia entry). The intended behaviour of methods from all Ext classes can be found in the Ext Documentation Center.
I agree that patch Animal proposed adds functionality, features to JsonReader and makes it more "bullet-proof". The fact that Jack hasn't added it to the trunk was his decision. Maybe he sacrificed functionality for stability as adding new features can introduce new bugs.
Anyway, I'm notifying Jack on this matter.Jozef Sakalos, aka Saki
A lot of valuable info at:
Saki's Extensions and Plugins
Saki's Extensions and Plugins Docs
Saki's Examples, Latest: Grid in Card Layout
Saki's Blog, Featured: Writing a Big Application in Ext, Latest: Grid MultiSearch Plugin Video
-
23 Sep 2007 7:48 AM #3
OK. At least, maybe clarify in the Docs that if not all fields referenced by the mapping attribute then JsonReader fails to load any data at all.
Thanks and sorry if this was already discussed and ignored - I didn't see any reference to this in the Bugs section.
-
17 Sep 2009 6:38 AM #4
I don't get it.
Here is the description of defaultValue for record definition.
Code:defaultValue : Mixed The default value used when a Record is being created by a Reader when the item referenced by the mapping does not exist in the data object (i.e. undefined). (defaults to "")
When country is not defined I would expect "N/A" to be displayed.Code:Ext.data.Record.create([ {name: 'firstName'}, {name: 'lastName'}, {name: 'countryName', mapping: 'country.name', defaultValue:"N/A"}, {name: 'contryState', mapping: 'country.state', defaultValue:"N/A"} ])
So maybe there is no bug in the JSONReader... but defaultValue definitely does not work!

-
17 Sep 2009 2:38 PM #5
Are you sure that you're going to use Ext 1.1.1? The current version is Ext 3.0.2 and Ext 1.x is not supported anymore.
Jozef Sakalos, aka Saki
A lot of valuable info at:
Saki's Extensions and Plugins
Saki's Extensions and Plugins Docs
Saki's Examples, Latest: Grid in Card Layout
Saki's Blog, Featured: Writing a Big Application in Ext, Latest: Grid MultiSearch Plugin Video
-
17 Sep 2009 10:57 PM #6
Thanks jsakalos for your answer. Of course I am not using Ext 1.x, but I'm now stock on V2.3.0. Want to migrate but I had encountered some serious performance issues when I had moved to 3.0.0.
I will be delighted to try the newest version. Thanks to all of you for this FANTASTIC tool.
-
17 Sep 2009 11:57 PM #7
I asked because this thread is 2 years old so any information in it can be obsolete.
Jozef Sakalos, aka Saki
A lot of valuable info at:
Saki's Extensions and Plugins
Saki's Extensions and Plugins Docs
Saki's Examples, Latest: Grid in Card Layout
Saki's Blog, Featured: Writing a Big Application in Ext, Latest: Grid MultiSearch Plugin Video






Reply With Quote