2
votes

I'm trying to write ExtJS app, which is grid, that loads data from JSON file on server, and sends modified fields back to server. Problem is, I can't manage to actually send changed or added data back to server script. Here's the code:

var store = Ext.create('Ext.data.Store', {
    model: 'ObjectDefinitionModel',
    autoDestroy: true,
    autoLoad: true,
    proxy: {
        type: 'ajax',
        url: 'load-object-definition',
        api: {
            read: 'load-object-definition',
            create: 'save-object-definition',
            update: 'update-object-definition',
            destroy: 'delete-object-definition'
        },
        reader: {
            type: 'json',
            root: 'fields'
        },
        writer: {
            type: 'json',
            root: 'fields'
        }
    }
});

And I have the button, which calls store.sync() when pressed. After syncinc, script in save-object-definition do execute, but all it receives (in both POST and GET) is [_dc] => 1311511955134,and I have no idea what it is. API documentation says that all changed and added data should be packed and sent automatically via proxy. And official examples don't show any data actually being sent, only some debug messages. Will appreciate any help, thanks in advance.

2
Try with autoSave : trueVarun Achar
Nope, didn't make any difference.lasquarte

2 Answers

0
votes

I also faced same issue in one of my project, where I was supposed to send only the newly added or updated records to the server for saving. I initially tried with the same method as posted by you here, but later (as it didn't work for me too) I created custom code to do the following:

a. When the user clicks the button to save, then browse through all the records of grid and identify the updated or newly added records.

b. Create a custom JSON containing all such records and fire an Ajax request to the server with this JSON as one of the parameter.

This all was definitely extra work, but finally served the purpose for me.

Hope this helps.

0
votes

ExtJS proxy really sending data, but using RAW POST. You may get them using the following function:

function GetRAWdata()
{
    $result = NULL;
    if(function_exists('json_decode'))
    {
        $jsonData = json_decode(trim(file_get_contents('php://input')), true);
        $result = $jsonData['data'][0];
    }
    return $result;
}