1. #1
    Sencha User
    Join Date
    Apr 2011
    Posts
    9
    Vote Rating
    0
    dshupe@comcast.net is on a distinguished road

      0  

    Default Unanswered: Why ajax proxy api update no json

    Unanswered: Why ajax proxy api update no json


    I am editing a cell with cellediting in a gridpanel, and I am calling store.update() and sync(). The proxy chooses the right operation.action, but my json looks like this in the POST tab in firebug: "data []".

    Here's my code:

    Ext.Loader.setConfig({
    enabled: true
    });
    Ext.Loader.setPath('Ext.ux', '/extjs4/examples/ux');
    Ext.require([
    'Ext.layout.container.Fit',
    'Ext.grid.*',
    'Ext.data.*',
    'Ext.util.*',
    'Ext.panel.*',
    'Ext.selection.CellModel',
    'Ext.state.*',
    'Ext.form.*',
    'Ext.ux.CheckColumn'
    ]);

    Ext.define('Ext.app.HirePlanGrid', {
    extend: 'Ext.panel.Panel',
    alias: 'widget.hirePlangrid'
    ,hireplanstoreId: 'hireplanstore'
    ,hiremonthstoreId: 'hiremonthstore'

    ,renderMonth : function (value, p, record) {
    var fkStore = Ext.getStore(this.up('hirePlangrid').hiremonthstoreId);
    var rec = fkStore.findRecord("MONTH_ID", value);
    //return rec.get("ABBREVIATED_MONTH");
    }

    ,initComponent: function(){
    var rIdx = '';
    var cIdx = '';

    this.editing = Ext.create('Ext.grid.plugin.CellEditing',
    {clicksToEdit: 1,
    listeners: {
    'beforeedit': function(e){
    var me = this;
    var allowed = !!me.isEditAllowed;
    if (!me.isEditAllowed)
    Ext.Msg.confirm('confirm', 'Are you sure?', function(btn){
    if (btn !== 'yes')
    return;
    me.isEditAllowed = true;
    me.startEditByPosition({
    row: e.rowIdx,
    column: e.colIdx
    });
    });
    rIdx = e.rowIdx;
    cIdx = e.colIdx;
    // alert('rIdx= ' + rIdx + ' cIdx = ' + cIdx);
    return allowed;
    },
    'edit': function(e){
    this.isEditAllowed = true;
    }
    }
    });

    var objMonthStore = Ext.getStore(this.hiremonthstoreId);
    objMonthStore.load();
    var objStore = Ext.getStore(this.hireplanstoreId);
    objStore.setProxy( {
    type: 'ajax',
    url: 'hireplan.cfc?method=getEmployees'
    });

    objStore.load();

    var onDeleteClick = function(field, value, options){
    // var objPanel = this.down('gridpanel');
    var selection = Ext.getCmp('grid').getSelectionModel().getSelection();
    // alert(selection);
    //var selection = getView().getSelectionModel().getSelection()[r];
    if (value) {
    //alert(value);
    objStore.remove(value);
    objStore.sync();
    }
    };
    var onUpdateClick = function(field, value, options){
    alert('field= ' + field + ' value= '+ value + 'options= '+ options);
    objStore.update(this.hireplanstoreId,value,'update',options);
    onSync();

    };
    var onSync = function(){
    objStore.sync();
    };

    Ext.apply(this, {
    layout: 'fit',
    width: 800,
    //height: 1500,
    items: [
    {
    xtype: 'grid',
    id : 'gridgrid',
    //height: 300,
    store: objStore,
    selModel: { selType: 'cellmodel' },
    selType : 'rowmodel',
    plugins: [this.editing],
    // plugins: [cellEditing],
    columnLines: true,
    viewConfig:{stripeRows: true},
    //loadMask: true,
    disableSelection: true,
    columns: [
    {header: 'rowid', hidden: true, dataIndex: 'ROWID'},
    {
    header: 'Indicator',
    id: 'chkcolumn',
    xtype: 'checkcolumn',
    dataIndex: 'CHK_COL',
    editor: {
    xtype: 'checkbox',
    cls: 'x-grid-checkheader-editor'
    }, listeners : {
    checkchange : function(column, recordIndex, checked)
    {
    alert('checked rindex= ' + recordIndex);
    onDeleteClick(column, recordIndex, checked);
    //or send a request
    }
    }
    },
    {
    id: 'employeeid',
    header: 'employeeid',
    width: 80,
    hidden: false,
    sortable: true,
    dataIndex: 'EMPLOYEEID',
    flex: 1
    },
    {
    id: 'NATIONALIDNUMBER',
    header: 'NATIONALIDNUMBER',
    width: 80,
    sortable: true,
    dataIndex: 'NATIONALIDNUMBER',
    flex: 1
    },
    {
    id: 'MARITALSTATUS',
    header: 'MARITALSTATUS',
    width: 80,
    sortable: true,
    dataIndex: 'MARITALSTATUS',
    flex: 1
    },
    {
    id: 'PotentialforInsourcingKV',
    header: 'Potential for Insourcing',
    width: 30,
    sortable: true,
    dataIndex: 'POTENTIAL_FOR_INSOURCING',
    flex: 1,
    editor: {
    id: 'thiscombo',
    xtype: 'combobox',
    typeAhead: true,
    triggerAction: 'all',
    selectOnTab: true,
    store: [
    ['1', 'Yes'],
    ['0', 'No']
    ],
    lazyRender: true,
    listClass: 'x-combo-list-small',
    listeners: {
    scope : this,
    'select' : function(){
    var selval = Ext.getCmp('thiscombo').getValue();
    var row = rIdx;
    //alert(selval + ' ' + rIdx);
    onUpdateClick('thiscombo', rIdx, selval );
    }
    }
    }
    },
    {
    id: 'ABBREVIATED_MONTH',
    header: 'ABBREVIATED_MONTH',
    width: 80,
    sortable: true,
    dataIndex: 'ABBREVIATED_MONTH',
    flex: 1,
    renderer: this.renderMonth,
    field: {
    xtype: 'combobox',
    store: Ext.getStore(this.hiremonthstoreId),
    typeAhead: true,
    lazyRender: true,
    queryMode: 'local',
    displayField: 'ABBREVIATED_MONTH',
    valueField: 'MONTH_ID',
    listClass: 'x-combo-list-small'

    }
    },
    {
    id: 'SALARIEDFLAG',
    header: 'SALARIEDFLAG',
    width: 80,
    sortable: true,
    dataIndex: 'SALARIEDFLAG',
    flex: 1
    }
    ],

    features: [
    {
    ftype: 'rowbody'
    }
    ]
    }
    ]
    });
    this.callParent(arguments);
    }, //initComponent
    onSelectChange: function(selModel, selections){
    this.down('#delete').setDisabled(selections.length === 0);
    },
    viewConfig: {
    },
    });
    // JavaScript Document
    // JavaScript Document

    hireplanstore = Ext.create("Ext.data.Store", {
    model: 'HiringPlan',
    //autoLoad: true,
    //autoSync: true,
    buffered: true,
    storeId: 'hireplanstore',
    remoteFilter: true

    ,proxy: {
    type: 'ajax',
    simpleSortMode: true,
    api: {
    read: 'hireplan.cfc?method=GetEmployees',
    update: 'hireplan.cfc?method=upEmployees',
    destroy: 'hireplan.cfc?method=delEmployees'
    },
    reader: {
    type: 'json'
    ,messageProperty: 'message',
    successProperty: 'success'
    ,root: 'data'
    },
    writer: {
    type: 'json',
    writeAllFields: false,
    root: 'data'
    },
    listeners: {
    exception: function(proxy, response, operation){
    Ext.MessageBox.show({
    title: 'ERROR from store',
    msg: operation.getError(),
    icon: Ext.MessageBox.ERROR,
    buttons: Ext.Msg.OK
    });
    }
    }
    }


    });
    //hireplanstore.pageSize = 10000;
    Ext.define('HiringPlan', {
    extend: 'Ext.data.Model',
    fields: [
    {name: 'ROWID' , type: 'string'},
    {name: 'EMPLOYEEID' , type: 'string'},
    {name: 'NATIONALIDNUMBER' , type: 'string'},
    {name: 'MARITALSTATUS' , type: 'string'},
    {name: 'GENDER' , type: 'string'},
    {name: 'POTENTIAL_FOR_INSOURCING' , type: 'integer'},
    {name: 'ABBREVIATED_MONTH' , type: 'string'},
    {name: 'SALARIEDFLAG' , type: 'string'},
    {name: 'CHK_COL' , type: 'bool'}
    ]

    });
    Last edited by dshupe@comcast.net; 24 Oct 2011 at 11:38 AM. Reason: code formatting was all messed up

  2. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,611
    Answers
    543
    Vote Rating
    326
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    Please wrap your code in CODE tags (# button on the editor toolbar).

    That's far too much code to be posting on a forum. Please make the effort to extract a small test case before posting.

Thread Participants: 1

Tags for this Thread