Results 1 to 4 of 4

Thread: MVC application and CRUD from Form

  1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    47
    Answers
    3
    Vote Rating
    0
      0  

    Default 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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,336
    Answers
    3885
    Vote Rating
    1296
      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 @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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 in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Mar 2012
    Posts
    47
    Answers
    3
    Vote Rating
    0
      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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,336
    Answers
    3885
    Vote Rating
    1296
      0  

    Default

    The only hard part is resolving the store. And that depends on how your app is architected.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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 in print!

    When posting code, please use BBCode's CODE tags.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •