1. #1
    Ext User 666ragez666's Avatar
    Join Date
    Jan 2009
    Posts
    110
    Vote Rating
    0
    666ragez666 is on a distinguished road

      0  

    Question Ext.Direct store create doesn't pass any params

    Ext.Direct store create doesn't pass any params


    Hello guys,

    just a quick question, we might have done some mistakes but I am not really sure.

    If you use this sample, you will see that Ext.Direct doesn't pass any parameters on the XHR call for creating the new record, how comes it doesn't the record content ?

    You can see the screenshot of firebug.

    Thanks for your help.

    Code:
    <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Stateful Array Grid Example</title>
    
        <!-- ** CSS ** -->
        <!-- base library -->
        <link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
    
        <!-- overrides to base library -->
    
        <!-- page specific -->
        <link rel="stylesheet" type="text/css" href="../shared/examples.css" />
        <link rel="stylesheet" type="text/css" href="grid-examples.css" />
    
        <style type=text/css>
            /* style rows on mouseover */
            .x-grid3-row-over .x-grid3-cell-inner {
                font-weight: bold;
            }
        </style>
    
        <!-- ** Javascript ** -->
        <!-- ExtJS library: base/adapter -->
        <script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>
    
        <!-- ExtJS library: all widgets -->
        <script type="text/javascript" src="../../ext-all.js"></script>
    
        <!-- overrides to base library -->
    
        <!-- page specific -->
        <script type="text/javascript">
        Ext.onReady(function(){
            Ext.app.REMOTING_API = {"url":"php\/router.php","type":"remoting","actions":{"Profile":[{"name":"read","len":1},{"name":"update","len":1},{"name":"create","len":1},{"name":"destroy","len":1}]}};
            
            Ext.Direct.addProvider(Ext.app.REMOTING_API);
            var store = new Ext.data.DirectStore({
                remoteSort: true,
                autoload: true,
                autoSave: true,
                root: 'calc', 
                totalProperty: 'total', 
                idProperty: 'id', 
                fields: ['id', 'name'],
                writer: new Ext.data.JsonWriter({
                    encode: true,
                    writeAllFields: true
                }), 
                api: {
                    read: Profile.read,
                    create: Profile.create,
                    update: Profile.update,
                    destroy: Profile.destroy
                },
                sortInfo: {
                    field: 'id',
                    direction: 'asc'
                }
            });
            
            store.load();
            var Employee = Ext.data.Record.create([{
                    name: 'id',
                    type: 'int'
                }, {
                    name: 'name',
                    type: 'string'
            }]);
            var e = new Employee({
                id: 0,
                name: 'new@exttest.com'
            });
            store.insert(0,e);
            
    
    
        });
        
        
        </script>
    
    </head>
    <body>
        
    </body>
    </html>
    Attached Images

  2. #2
    Sencha - Services Team Stju's Avatar
    Join Date
    Dec 2008
    Location
    Redwood city, California
    Posts
    287
    Vote Rating
    3
    Stju is on a distinguished road

      0  

    Default


    Look at serverside code! Do you have read, create e.t.c functions defined and with correct amount of parameters?
    It's the first thing to check for, if some parameters are not passed or they amount is wrong!

    Also check this and compare, some things are missing...
    Code:
    // Store Writer
    this.storeWriter = new Ext.data.JsonWriter({
        encode: false
    });
    
    // Direct Store
    this.prefStore = new Ext.data.DirectStore({
        api: {
            read: preferencesEditorDIRECT.readData,
            create: preferencesEditorDIRECT.createData,
            update: preferencesEditorDIRECT.updateData,
            destroy: preferencesEditorDIRECT.removeData
        },
        paramOrder: ['sort','dir','start','limit','fields','query'],
        autoLoad : true,
        autoSave: true, // <- INPORTANT to send data automatically to server!
        batchSave: false,
        prettyUrls: false,
    
        writer: this.storeWriter,
    
        root: 'data',
        idProperty: 'id',
        totalProperty: 'total',
        successProperty: 'success',
        paramsAsHash: false, //important
    
        paramsNames: { start : 'start', limit : 'limit', sort : 'sort', dir : 'dir'},
        remoteSort: true,
        baseParams: {
            start : 0,    // jabut INT!
            limit : 20,    // jabut INT!
            sort : 'pref_name',
            dir : 'ASC'
        },
        fields: [
            { name: 'id', type: 'int'},
            .. field names! ..
        ],
        listeners : {
            loadexception : function()
            {
              alert('Store LOAD EXCEPTION! Please restart Your browser');
            },
            update : function()
            {
                this.store.commitChanges();
            },
            scope:this
        }
    });
    Last edited by Stju; 26 Apr 2010 at 1:22 AM. Reason: Added sample code..

  3. #3
    Sencha User
    Join Date
    Apr 2009
    Location
    / .de / ST / HAL
    Posts
    33
    Vote Rating
    0
    Matthias_WB is on a distinguished road

      0  

    Default


    Hello!

    Look at serverside code! Do you have read, create e.t.c functions defined and with correct amount of parameters?
    It's the first thing to check for, if some parameters are not passed or they amount is wrong!
    Can you post the correct server-parameters??? Ihave the same probles as the thread-starter...
    Best regards

    Matthias

    _______________
    ExtJS is the best ajax-framework, that I know!

Thread Participants: 2

Tags for this Thread