Results 1 to 3 of 3

Thread: Data Writers not sending data!

  1. #1
    Sencha User
    Join Date
    Apr 2011

    Exclamation Data Writers not sending data!

    Hello All,
    I'm trying to create a Grid with a row editor that will work with a REST service I have written. My problem is that my REST service is not recieving any data! I've tried both the Json, and Xml writers. Both access the correct URI ( /api/rest/documents/24 for example ). However, neither seems to be sending any parameters! I was previously working with ExtJS 3, and had a custom writer that just sent a set of keys in the standard POST/GET key=data style, but I don't have the know-how to rewrite it for ExtJS 4. Any idea what I am doing wrong?

    Thanks in advance,

    Here is my code:
    Ext.require(['*', 'Ext.grid.*']);
    Ext.define('Document', {
        extend: '',
        fields: [
                name: 'id',
                type: 'int',
                useNull: true,
                name: 'name',
                type: 'text',
                useNull: 'true',
        var writer = new;
        var reader = new{
                    type: 'json',
                    root: 'items',
                    totalProperty  : 'total',
                    successProperty: 'success'                    
        var store = Ext.create('', {
            autoLoad: true,
            autoSync: true,
            remoteSort: true,
            model: 'Document',
            proxy: {
                type: 'rest',
                url: '/api/rest/documents',
                headers: {
                      'Accept' : 'application/json'
                reader: reader,
                writer: writer,
        var bbar = new Ext.PagingToolbar({
            //pageSize: 10,
            store: store
        var rowEditing = Ext.create('Ext.grid.plugin.RowEditing');
        var grid = Ext.create('Ext.grid.Panel', {
            renderTo: 'documents-grid',
            plugins: [rowEditing],
            width: 400,
            height: 300,
            frame: true,
            title: 'Documents',
            store: store,
            iconCls: 'icon-user',
            bbar: bbar,
            columns: [
                    text: 'ID',
                    width: 40,
                    sortable: true,
                    dataIndex: 'id',
                    renderer: function(v){
                        if (Ext.isEmpty(v)) {
                            v = ' '
                        return v;
                    text: 'Name',
                    flex: 1,
                    sortable: true,
                    dataIndex: 'name',
                    field: {
                        xtype: 'textfield'
            dockedItems: [{
                xtype: 'toolbar',
                items: [{
                    text: 'Add',
                    iconCls: 'icon-add',
                    handler: function(){
                        // empty record
                        store.insert(0, new Document());
                        rowEditing.startEdit(0, 0);
                }, '-', {
                    text: 'Delete',
                    iconCls: 'icon-delete',
                    handler: function(){
                        var selection = grid.getView().getSelectionModel().getSelection()[0];
                        if (selection) {

  2. #2


    Using Firebug, check the request being made. It may be sending the params, except not in traditional key=val format.

    I know that the AJAX Proxy, by default (and by an UNOVERRIDABLE DEFAULT NONETHELESS), encodes data as JSON for the request. Perhaps the REST Proxy does the same.

    If you find any way to override how a proxy encodes its data (not just sort/group/filter params, but actual model data), PLEASE PLEASE PLEASE let me know!

  3. #3
    Sencha User
    Join Date
    Apr 2011

    Default Key/Val Writer

    In the end, I was able to recreate my simple writer in Ext JS 4. Here is the code. I'm pretty sure this will break if a key is used multiple times. I'm not sure how to handle that issue.

     * @class
     * @extends
     * @ignore
    Ext.define('', {
        extend: '',
        alternateClassName: '',
        alias: '',
        writeRecords: function(request, data) {
            for( d in data ) {
                    for( key in data[d] ) {
                            //This probably needs to be modified to work
                            //with arrays of data larger then 1
                            request.params[key] = data[d][key];
            return request;

Similar Threads

  1. Ajax Requests from Data Writers
    By mcamer in forum Ext 3.x: Help & Discussion
    Replies: 4
    Last Post: 21 Jul 2010, 9:48 AM
  2. Sending data from textfield
    By MalcolmHaslam in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 2 Jul 2009, 8:09 AM
  3. Sending data
    By oasisjoel in forum Ext 2.x: Help & Discussion
    Replies: 13
    Last Post: 3 May 2009, 6:08 PM
  4. Issue with sending data
    By border9 in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 30 Oct 2008, 8:50 AM
  5. Sending data with AJAX
    By Zolcsi in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 25 Dec 2007, 4:48 AM

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