2 * @example Model with Proxy
4 * This example demonstrates using a {@link Ext.data.proxy.Proxy} directly on a {@link Ext.data.Model}
5 * The data is loaded and saved using a dummy rest api at url `data/users`. You should see messages appear
6 * in your console when the data is loaded and saved.
7 * A global variable called "userStore" is created which is an instance of {@link Ext.data.Store}.
8 * Feel free to experiment with the "userStore" object on the console command line.
11 extend: 'Ext.data.Model',
12 fields: ['id', 'name', 'age'],
24 Ext.require('Ext.data.Store');
25 Ext.onReady(function() {
26 // Uses the User Model's Proxy
27 userStore = Ext.create('Ext.data.Store', {
32 // Gives us a reference to the User class
33 var User = Ext.ModelMgr.getModel('User');
35 var ed = Ext.create('User', {
40 // We can save Ed directly without having to add him to a Store first because we
41 // configured a RestProxy this will automatically send a POST request to the url data/users
43 success: function(ed) {
44 console.log("Saved Ed! His ID is "+ ed.getId());
48 // Load User 1 and do something with it (performs a GET request to /users/1)
50 success: function(user) {
51 console.log("Loaded user 1: " + user.get('name'));