Results 1 to 3 of 3

Thread: Sending data from Grid in browser to server side

  1. #1
    Sencha User
    Join Date
    Jan 2012
    Location
    New York City
    Posts
    109
    Answers
    1
    Vote Rating
    2
      0  

    Default Answered: Sending data from Grid in browser to server side

    Hello,

    I am completely new to ExtJS as well as web development in general. I am trying to create a simple ExtJS 4 site with a Servlet on the server side.

    I have a hard coded number of rows in a grid, and have a submit button associated with the grid. When the button is pressed I would like all of the data in the grid (possibly some of the data later on) to be sent to the server and processed by my Java controller.

    Unfortunately I am not seeing any data being sent as parameters to the server. Request is definitely being sent but I dont see any params but '_dc'. How can this data be sent to the server via in a json format? I have tried the store.save() function and the store.load() function but neither automatically send the data in json format to the server (bolded below).

    Your help is greatly appreciated!!!

    Code is below:

    --Model
    Ext.define('DMT.model.PersonGeoUnitModel', {
    extend: 'Ext.data.Model',
    fields: [
    {name: 'sso_id', type: 'string'},
    {name: 'sso_type', type: 'string'},
    {name: 'geo_unit_purpose', type: 'string'},
    {name: 'geo_unit_type', type: 'string'},
    {name: 'geo_unit_value', type: 'string'},
    {name: 'gs_data_source_id', type: 'string'},
    {name: 'start_date', type: 'date'},
    {name: 'end_date', type: 'date'},
    {name: 'update_date', type: 'date'},
    {name: 'update_id', type: 'string'},
    {name: 'tax_id_type', type: 'string'},
    {name: 'tax_id', type: 'string'},
    {name: 'transaction_type', type: 'string'},
    {name: 'delete_row', type: 'bool'}]
    });

    --Store
    Ext.define('DMT.store.FakeData', {
    extend: 'Ext.data.Store',
    model: 'DMT.model.PersonGeoUnitModel',
    alias : 'widget.fakeDataStore',

    proxy: {
    type: 'ajax',
    url: '/DMT/index.htm',
    reader: {
    type: 'json',
    root: 'data',
    successProperty: 'success'
    },
    writer: {
    type: 'json'
    }
    },


    data: [
    {sso_id: 'abc_def', geo_unit_purpose: 'LICENSE', geo_unit_type: 'COUNTRY', geo_unit_value: 'HK', tax_id_type: 'ANLLICID',
    tax_id: 'ABCD123'},
    {sso_id: 'someone_else', geo_unit_purpose: 'LICENSE', geo_unit_type: 'COUNTRY', geo_unit_value: 'HK', tax_id_type: 'ANLLICID',
    tax_id: 'ABCD456'}
    ]
    });


    --View

    Ext.define('DMT.view.PersonGeoUnitView' ,{
    extend: 'Ext.grid.Panel',
    alias : 'widget.personGeoUnitView',

    title : 'GeoUnitUpdate',
    store: 'FakeData',
    selType: 'cellmodel',

    plugins: [
    Ext.create('Ext.grid.plugin.CellEditing', {
    clicksToEdit: 1
    })
    ],

    dockedItems: [{
    xtype: 'toolbar',
    dock: 'top',
    ui: 'footer',
    layout: {
    pack: 'left'
    },
    items: [
    { xtype: 'component', flex: 1 },
    { xtype: 'button', text: 'Submit', width: 80, listeners: {
    'click': function() {
    var thisStore = Ext.widget('fakeDataStore');
    thisStore.save();
    */
    alert(thisStore.load(function(records, operation, success) {
    console.log(records);

    }));*/


    }}}
    ]
    }],

    initComponent: function() {

    this.columns = [
    {header: 'SSO_ID', dataIndex: 'sso_id', flex: 1, hideable: false},
    {header: 'SSO_TYPE', dataIndex: 'sso_type', flex: 1, hidden: true, hideable: false},
    {header: 'GEO_UNIT_PURPOSE', dataIndex: 'geo_unit_purpose', flex: 1, hideable: false},
    {header: 'GEO_UNIT_TYPE', dataIndex: 'geo_unit_type', flex: 1, hideable: false},
    {header: 'GEO_UNIT_VALUE', dataIndex: 'geo_unit_value', flex: 1, editor: 'textfield', hideable: false},
    {header: 'GS_DATA_SOURCE_ID', dataIndex: 'gs_data_source_id', flex: 1, hidden: true, hideable: false},
    {header: 'START_DATE', dataIndex: 'start_date', flex: 1, hidden: true, hideable: false},
    {header: 'END_DATE', dataIndex: 'end_date', flex: 1, hidden: true, hideable: false},
    {header: 'UPDATE_DATE', dataIndex: 'update_date', flex: 1, hidden: true, hideable: false},
    {header: 'UPDATE_ID', dataIndex: 'update_id', flex: 1, hidden: true, hideable: false},
    {header: 'TAX_ID_TYPE', dataIndex: 'tax_id_type', flex: 1, editor: 'textfield', hideable: false},
    {header: 'TAX_ID', dataIndex: 'tax_id', flex: 1, editor: 'textfield', hideable: false},
    {header: 'TRANSACTION_TYPE', dataIndex: 'transaction_type', flex: 1, hidden: true, hideable: false},
    {header: 'DELETE', dataIndex: 'delete_row', xtype: 'checkcolumn', width: 80, editor: 'checkbox', sortable: false, hideable: false}
    ];

    this.callParent(arguments);
    }
    });

  2. You could use a writer on your store and execute sync (or use autoSync)

    http://docs.sencha.com/ext-js/4-0/#!...er/writer.html

  3. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,381
    Answers
    3997
    Vote Rating
    1536
      0  

    Default

    You could use a writer on your store and execute sync (or use autoSync)

    http://docs.sencha.com/ext-js/4-0/#!...er/writer.html
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  4. #3
    Sencha User
    Join Date
    Jan 2012
    Location
    New York City
    Posts
    109
    Answers
    1
    Vote Rating
    2
      0  

    Default

    Awesome thanks, I couldnt find any specifics in the basic docs specifying that a writer was needed for this purpose.

    Digging a little deeper, I was wondering, if we did not want to send the entire store to the server side, but just particular rows (ex: rows that are even, or rows that have been updated/added), what would be the best practice to do something like this? Off the top of my head I would remove the rows on the client side from the store and then send the store via sync() as mentioned above but wondering if there was a better way.

    Also, what does the function save() do different than sync()?

    Cheers,

    Jason

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
  •