Results 1 to 3 of 3

Thread: GRID CRUD (REST) -> Only able to get "GET" and "POST"

  1. #1
    Sencha User
    Join Date
    Apr 2013
    Posts
    26
    Vote Rating
    0
      0  

    Default Answered: GRID CRUD (REST) -> Only able to get "GET" and "POST"

    Hi all,
    i have worked on a grid in Sencha Architect 2.2 (Ext.JS).

    grid_start.jpg

    I used RowEditingPluing to edit each line:
    grid_rowSelected.jpg

    But i use 2 different JSON-Files:
    1) Main-JSON-File ("Users"):
    Code:
    Ext.define('MyApp.store.Users', {    extend: 'Ext.data.Store',
    
    
        requires: [
            'MyApp.model.User'
        ],
    
    
        constructor: function(cfg) {
            var me = this;
            cfg = cfg || {};
            me.callParent([Ext.apply({
                autoLoad: true,
                autoSync: true,
                model: 'MyApp.model.User',
                storeId: 'Users',
                proxy: {
                    type: 'ajax',
                    url: 'http://localhost/sencha/api/user',
                    reader: {
                        type: 'json',
                        idProperty: 'id',
                        root: 'data'
                    }
                }
            }, cfg)]);
        }
    });
    Second JSON-File ("contact"):
    Code:
    Ext.define('MyApp.store.Contacts', {    extend: 'Ext.data.Store',
    
    
        requires: [
            'MyApp.model.Contact'
        ],
    
    
        constructor: function(cfg) {
            var me = this;
            cfg = cfg || {};
            me.callParent([Ext.apply({
                autoLoad: true,
                autoSync: true,
                model: 'MyApp.model.Contact',
                storeId: 'MyJsonStore1',
                proxy: {
                    type: 'ajax',
                    url: 'http://localhost/sencha/api/contact',
                    reader: {
                        type: 'json',
                        root: 'data'
                    }
                }
            }, cfg)]);
        }
    });
    My Model "User":
    Code:
    Ext.define('MyApp.model.User', {    extend: 'Ext.data.Model',
    
    
        clientIdProperty: 'id',
    
    
        fields: [
            {
                name: 'name'
            },
            {
                name: 'emailAddress'
            },
            {
                name: 'age'
            },
            {
                name: 'birthdate',
                type: 'date'
            },
            {
                name: 'gender'
            },
            {
                name: 'getNewsletter',
                type: 'boolean'
            },
            {
                name: 'contactFK'
            },
            {
                name: 'id'
            }
        ]
    });
    My Model "Contact":
    Code:
    Ext.define('MyApp.model.Contact', {    extend: 'Ext.data.Model',
    
    
        fields: [
            {
                name: 'ContactID'
            },
            {
                name: 'Name'
            },
            {
                name: 'SourceContacTID'
            },
            {
                name: 'CustomerFK'
            },
            {
                name: 'DateCreated'
            },
            {
                name: 'BasePriority'
            }
        ]
    });
    Contact is used to fill a dropdown ( combobox ) in the grid.

    If i "update" some row, i get following request:
    • Request URL:
      http://localhost/sencha/api/user?_dc=1366617771342
    • Request Method:
      POST
    • Status Code:
      201 Created
    • age: 30
    • birthdate: "1930-01-01T00:00:00"
    • contactFK: 8296
    • emailAddress: "billie@test.com"
    • gender: "M"
    • getNewsletter: true
    • id: 68
    • name: "Billy Tinnes"[/CODE]

    • in JSON there is an ID, but it should be sent like sencha/api/user/{id}

      How do i solve it?

      I didn't try delete yet, but i guess it will be the same?
      Anyone has an idea how to solve it?

      Thanks alot.





  2. Have you tried using a Rest proxy?

    http://docs.sencha.com/extjs/4.2.0/#...ata.proxy.Rest

  3. #2
    Sencha User existdissolve's Avatar
    Join Date
    Jan 2010
    Location
    Kansas
    Posts
    522
    Answers
    32
    Vote Rating
    88
      0  

    Default

    Have you tried using a Rest proxy?

    http://docs.sencha.com/extjs/4.2.0/#...ata.proxy.Rest

  4. #3
    Sencha User
    Join Date
    Apr 2013
    Posts
    26
    Vote Rating
    0
      0  

    Default

    Hi existdissolve,
    thanks a lot, i didn't see the obvious thing.

    In my store i changed my Ajax-proxy to REST-proxy (copied and pasted the url "
    http://localhost/sencha/api/user") and it worked.

    Thanks so much.
    So, this "problem" is solved
    Last edited by BastianKrones; 23 Apr 2013 at 5:18 AM. Reason: Just changed color of "So this is solved".

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
  •