PDA

View Full Version : model.getId() with custom IdProperty fails when store.fields set via metaData



hdave
21 Jan 2014, 8:51 AM
ExtJS 4.2.2

I have a reader (inherits from JSON reader) in which I setup metadata that includes the fields that the Store that owns this Reader should use:


response.metaData = {
? idProperty : '_id',
fields : fields
};





On this reader I also have also specified this custom idProperty:


idProperty : '_id',




I do not create a dynamic model on-the-fly, I am relying on the store to catch the new metadata coming from the reader and create a model dynamically. All of this works as documented here:

http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.data.reader.Json

The bug I am reporting is that the getId() function on the resulting model records returns "undefined" instead of the value of the field named "_id". I realize that I am not explicitly creating a model here, but I would still have expected this to work.

An important side effect of this bug is that if I "sync" my store which results in POST or PUT responses, the record read from those responses cannot return its ID, which makes updating the _id property of the phantom record in the store fail. I believe that the on-the-fly model created by the framework in response to the presence of metadata fields should use the value of idProperty such that the model's getId() function works as expected.

I do not yet have a workaround for this.

Gary Schlosberg
24 Jan 2014, 2:16 PM
Thanks for the report! Can you please post a test case which reproduces the issue?