PDA

View Full Version : [CLOSED] getRecordsValues and nested data



bogc
Feb 22, 2013, 3:52 AM
Hi:

If I want to pass the content of a Store to an .Net MVC action controller and take into account nested data, what is the best way to do it?

When I say nested data, I mean the store has a model with HasMany associations, for instance, an Order and its Line Items.

I searched the samples and I couldn't find anything concrete.

I could use on the client side Ext.encode(someStore.getRecordsValues()) but getRecordsValues doesn't seem to copy the nested data.

Also, is StoreDataHandler capable of deserializing nested data?

Thank you

Vladimir
Feb 22, 2013, 9:27 AM
Hi,

'getRecordsValues' return from model fields only, if you need to add extra information then you have to do it manually (getRecordsValues returns array of objects therefore you can add any required data top each object)



Also, is StoreDataHandler capable of deserializing nested data?

StoreDataHandler is not designed for custom requests, it should be used for sync/load requests of Store
You can use JSON.Deserialize method in controller action, deserialization is based on server side type which passed to Deserialize generic method therefore server side type should have corresponding properties to correct deserialization

Why do you need to pass data from associations with base store data? Is data from asscociations changed on the client side and not available on the server side?

bogc
Feb 22, 2013, 4:51 PM
Is data from associations changed on the client side and not available on the server side?

Yes, that is correct. I have a scenario where the child records might be modified but not the parents. I have a 3 level hierarchy (think of Order, Line Items and for each Line Item descriptions in various languages).

One more question, is sync sending all the child changes to the server, even when the parent didn't change but the children changed?

Thanks

Vladimir
Feb 22, 2013, 5:07 PM
sync request sends only dirty records and data includes fields only (fields are defined in the model)
You can mark record as dirty by calling setDirty method of record

Also you can save associated data separately like in the following sample
http://examples2.ext.net/#/Associations/HasMany/Simple_Lazy_Load/