-
11 Apr 2012 8:45 AM #1
Unanswered: MVC application and CRUD from Form
Unanswered: MVC application and CRUD from Form
Hi,
I'm working on an MVC structured application and i have to do some CRUD operations (add, remove and update).
I have successfully loaded my datas from the local JSON and i can show them into fields in a form. But i don't know how to do CRUD operations using the proxy, store and model.
Here is my code :
Model file : Prospect.js
Code:Ext.define('pharmapp.model.Prospect', { extend: 'Ext.data.Model', config: { fields: [ 'nom', 'prenom', 'adresse', 'email', 'telephone', 'datenaissance', 'enfants', 'conjoint', 'cv', 'autre', 'profilage', 'secteur', 'region', 'specialite', 'grade' ] }, });
Store file : Prospects.js
and i have a controller file Prospects.js that's supposed doing the actions mentioned above.Code:Ext.define('pharmapp.store.Prospects', { extend: 'Ext.data.Store', config: { model: 'pharmapp.model.Prospect', sorters: 'nom', grouper : function(record) { return record.get('prenom')[0]; }, autoLoad: true, proxy:{ type: 'rest', url: 'app/data/prospects.json', reader: { type: 'json' } } } });
Thanks for your help
-
11 Apr 2012 9:29 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 436
- Answers
- 3113
Since you are using a store, if you add, update or remove a record from the store you can call sync() on the store and with a writer it will send a request to the server describing this change
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
11 Apr 2012 10:20 AM #3
my problem is that i don't know how to pass information to the store from the controller. the only examples that i found describes how to do it in other ways and not MVC.
-
11 Apr 2012 11:31 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 436
- Answers
- 3113
The only hard part is resolving the store. And that depends on how your app is architected.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.


Reply With Quote