I have two stores:
FAQs
- contains a lot of models of my itemsFAQ
- contains one model.
In view mode I work with FAQs
(to see all items) and in edit mode I work with FAQ
just to work with one item and not to load all of them.
After finishing editing and saving FAQ
I need to find that item in FAQs
and make changes there as I've made in FAQ
. I don't use network for it.
I know two ways:
1) find needed record in FAQs
and replace it there
_updateFaqsStore: function() {
var faqsStore = Ext.data.StoreManager.lookup("faqs.FAQs");
var activeRec = this.activeRecord;
var index = faqsStore.indexOf( faqsStore.findRecord('id',activeRec.get('id')) ); // index in faqsStore of activeRec
faqsStore.remove(faqsStore.findRecord('id',activeRec.get('id'))); // remove old rec
faqsStore.insert(index, activeRec); // insert new - activeRec
but the object structure is not the same (though I use the same model)
2) find needed record in FAQs
and set there every field
var faqsItem = faqsStore.findRecord('id', activeRec.get('id')); // find same item in FAQs store
faqsItem.set("myField", activeRec.get('myField')); // make changes in FAQs as in FAQ
but I need to enumerate all fields.
Maybe, there is some other way out? Please, help me!
I don't use network
? Where do you get those data's? – Oğuz Çelikdemir