1. #1
    Sencha User
    Join Date
    Mar 2013
    Posts
    6
    Vote Rating
    0
    jeongyej is on a distinguished road

      0  

    Default Unanswered: How to send data into server-side by using Ext.data.DirectStore

    Unanswered: How to send data into server-side by using Ext.data.DirectStore


    Can someone help me out resolve below issue ?

    I'm using Ext.data.DirectStore to do CRUD action in gridPane.
    I'm done with loding data from the server successfully, but I got serious error when I tried to remoe record in grid and sync().

    Currently, I'm developing it by MVC pattern and below is the store that I defined.

    Code:
     Ext.define('DirectApp.store.DirectStore', {
     extend : 'Ext.data.DirectStore',
     constructor : function(cfg){
      cfg = Ext.apply(this, {
       storeId : 'directStore',
       model : 'DirectApp.model.DirectModel',   
       proxy : {
        type : 'direct',
        api : {
         read : DirectSvcImpl.getPersonalAllRPC
        },
        writer : new Ext.data.JsonWriter({
         type : 'json',
         encode : true,
         writeAllFields : true
        })
       },
       autoLoad : true
      });      
      this.callParent([cfg]);
     }
    });
    Below is the grid panel and I added toolbar to modify or remove record.

    Code:
    Ext.define('DirectApp.view.DirectGrid', {
     extend : 'web.common.client.GridPanel',
     xtype : 'DirectGrid',
     initComponent : function(){
      Ext.apply(this, {
       id : 'directGrid',
       width : 700,
       height : 400,
       columns : columns,
       checkbox : true,
       tbar : tbar,
       store : Ext.data.StoreManager.get('directStore')
      });
      this.callParent(arguments);
     }
    });
    
    var columns = [
     {text : 'ID',      dataIndex : 'id',      width : 70,       menuDisabled : true, sortable : false, align : 'right'},
     {text : 'First Name',  dataIndex : 'firstName',  width : 100,      menuDisabled : true, sortable : false, align : 'center'},
     {text : 'Last Name',  dataIndex : 'lastName',   width : 70,       menuDisabled : true, sortable : false, align : 'center'},
     {text : 'Company',   dataIndex : 'company',   width : 100,      menuDisabled : true, sortable : false, align : 'center'},
     {text : 'E-Mail',    dataIndex : 'email',    width : 100,      menuDisabled : true, sortable : false, align : 'center'},
     {text : 'Birth',    dataIndex : 'dob',     width : 100,      menuDisabled : true, sortable : false, align : 'center'},
     {text : 'Age',     dataIndex : 'age',     width : 50,       menuDisabled : true, sortable : false, align : 'right'},
     {text : 'Coworker',   dataIndex : 'coworker',   width : 100,      menuDisabled : true, sortable : false, align : 'center'}
    ];
    var tbar = Ext.create('Ext.toolbar.Toolbar', {
     items : [{
      text : 'Edit',
      handler : function(){
       var s = Ext.getCmp('directGrid').getStore(); 
       s.sync();
      }  
     },'-',{
      text : 'Remove',
      handler : function(){
       var s = Ext.getCmp('directGrid').getStore();
       s.removeAt(0);   
       s.sync();
      }
     },'-']
    });
    
    
    
    
    When I treid to click "Remove" button, I got error.



    TypeError: fn is undefined

    fn.apply(window, args);

    Below is the detailed error.

    Ext.apply(request, {
    args: args,
    directFn: fn
    });
    args.push(me.createRequestCallback(request, operation, callback, scope), me);
    fn.apply(window, args)

    For referene, when I added proxy options, "directFn", this error disappear.
    However, I want to use proxy api options.

    Lastly, How can I send removed data to server side when I treid to sync store ?

    Please give me an advice.

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,197
    Vote Rating
    482
    Answers
    690
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      1  

    Default


    You can use extraParams in the proxy

    Code:
    proxy : {
        extraParams: {
            // params
        }
    }

  3. #3
    Sencha User
    Join Date
    Mar 2013
    Posts
    6
    Vote Rating
    0
    jeongyej is on a distinguished road

      0  

    Default How can I handle store problem ?

    How can I handle store problem ?


    Thanks for your reply.
    One moe question, How can I handle store problem that currently I treid to click the "remove" button,
    it shows like below.

    TypeError: fn is undefined
    fn.apply(window, args)

    For reference, it disappear when I defined "directFn" property at proxy.
    I heard "api" property replace "directFn". Am I wrong?

Thread Participants: 1

Tags for this Thread