infernoz
19 Jan 2012, 10:39 AM
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);
}
});
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);
}
});