PDA

View Full Version : Load Form Values in to Memory Store



PV-Patrick
4 Jun 2012, 3:24 PM
I have been trying to get this to work all day and haven't quite figured it out, I'm sure it's probably something small. :((

I want to load some form values in to a memory store, I don't need AJAX or anything going to the server, it's just for display purposes in a template on the page. What's the proper way to go about this? It seems fairly straight forward but I haven't been able to get anything to work in several hours, thanks!

Note: The store load is being triggered by combobox selections.

vietits
4 Jun 2012, 5:20 PM
Example code


Ext.define('Model', {
extend: 'Ext.data.Model',
fields: [ 'f1', 'f2', 'f3']
});


var store = Ext.create('Ext.data.Store', {
model: 'Model',
proxy: 'memory'
});

var values = <your form>.getForm().getValues();
store.add(values);

PV-Patrick
4 Jun 2012, 7:04 PM
Thank you vietits! Not having a Model and using just fields in the store seemed to be the issue.

vietits
4 Jun 2012, 7:24 PM
I encountered no problem without model.


var store = Ext.create('Ext.data.Store', {
fields: [ 'f1', 'f2', 'f3'],
proxy: 'memory'
});

store.add({f1:1, f2: 2, f3: 3});
console.log(store)

PV-Patrick
4 Jun 2012, 7:30 PM
Ya, it was a mixture of that and not using the add method. I was trying to use the load(s)