1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    47
    Vote Rating
    0
    Answers
    3
    romulus2012 is on a distinguished road

      0  

    Default 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

    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'
    			}
    	   }
        }
    });
    and i have a controller file Prospects.js that's supposed doing the actions mentioned above.


    Thanks for your help

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,714
    Vote Rating
    436
    Answers
    3113
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    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.

  3. #3
    Sencha User
    Join Date
    Mar 2012
    Posts
    47
    Vote Rating
    0
    Answers
    3
    romulus2012 is on a distinguished road

      0  

    Default


    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.

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,714
    Vote Rating
    436
    Answers
    3113
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    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.