infernoz
25 Jan 2012, 1:55 PM
Hello,
I have a GridPanel with a Store associated with it, and a button in the panels layout. When the button is pressed, I call store.sync() which calls my servlet on my server that I have configured via Proxy and all of the data in the store is sent (turned autosync off for functionality reasons). Fine and great :).
However I have noticed two things:
1. My grid is editable and when I edit my grid, the new data is not in the store, so when I call store.sync() the data originally in the grid is sent to the server not my new data. How do I make sure the data that is in the grid is sent to the server (ie: how do I sync my panel and store before the stores proxy sends data to the server)?
2. When my store.sync() response comes back my json object is in the response, however my data is not being updated in my grid panel. How do I make sure that my panel and store are bothupdated with the json response from the server?
Here is some snippets of code: Thanks for your help!
View - GridPanel
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.sync();
}}}
]
}],
initComponent: function() {
this.columns = [
{header: 'SSO_ID', dataIndex: 'ssoId', flex: 1, hideable: false},
{header: 'SSO_TYPE', dataIndex: 'ssoType', flex: 1, hidden: true, hideable: false},
{header: 'GEO_UNIT_PURPOSE', dataIndex: 'geoUnitPurpose', flex: 1, hideable: false},
{header: 'GEO_UNIT_TYPE', dataIndex: 'geoUnitType', flex: 1, hideable: false},
{header: 'GEO_UNIT_VALUE', dataIndex: 'geoUnitValue', flex: 1, editor: 'textfield', hideable: false},
{header: 'GS_DATA_SOURCE_ID', dataIndex: 'gsDataSourceId', flex: 1, hidden: true, hideable: false},
{header: 'START_DATE', dataIndex: 'startDate', flex: 1, hidden: true, hideable: false},
{header: 'END_DATE', dataIndex: 'endDate', flex: 1, hidden: true, hideable: false},
{header: 'UPDATE_DATE', dataIndex: 'updateDate', flex: 1, hidden: true, hideable: false},
{header: 'UPDATE_ID', dataIndex: 'updateId', flex: 1, hidden: true, hideable: false},
{header: 'TAX_ID_TYPE', dataIndex: 'taxIdType', flex: 1, editor: 'textfield', hideable: false},
{header: 'TAX_ID', dataIndex: 'taxId', flex: 1, editor: 'textfield', hideable: false},
{header: 'TRANSACTION_TYPE', dataIndex: 'transactionType', flex: 1, hidden: true, hideable: false},
{header: 'DELETE', dataIndex: 'deleteRow', xtype: 'checkcolumn', width: 80, editor: 'checkbox', sortable: false, hideable: false}
];
this.callParent(arguments);
}
});
- Store and Proxy
Ext.define('DMT.store.FakeData', {
extend: 'Ext.data.Store',
model: 'DMT.model.PersonGeoUnitModel',
alias : 'widget.fakeDataStore',
proxy: {
type: 'ajax',
url: '/DMT/index.html',
reader: {
type: 'json',
root: 'data',
idProperty: 'id'
},
writer: {
type: 'json',
root: 'data',
encode: true,
writeAllFields: true
}
},
data: [
{ssoId: 'abc', geoUnitPurpose: 'LICENSE', geoUnitType: 'COUNTRY', geoUnitValue: 'HK', taxIdType: 'ANLLICID',
taxId: 'ABCD123'},
{ssoId: 'someone_else', geoUnitPurpose: 'LICENSE', geoUnitType: 'COUNTRY', geoUnitValue: 'HK', taxIdType: 'ANLLICID',
taxId: 'ABCD456'}
]
});
I have a GridPanel with a Store associated with it, and a button in the panels layout. When the button is pressed, I call store.sync() which calls my servlet on my server that I have configured via Proxy and all of the data in the store is sent (turned autosync off for functionality reasons). Fine and great :).
However I have noticed two things:
1. My grid is editable and when I edit my grid, the new data is not in the store, so when I call store.sync() the data originally in the grid is sent to the server not my new data. How do I make sure the data that is in the grid is sent to the server (ie: how do I sync my panel and store before the stores proxy sends data to the server)?
2. When my store.sync() response comes back my json object is in the response, however my data is not being updated in my grid panel. How do I make sure that my panel and store are bothupdated with the json response from the server?
Here is some snippets of code: Thanks for your help!
View - GridPanel
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.sync();
}}}
]
}],
initComponent: function() {
this.columns = [
{header: 'SSO_ID', dataIndex: 'ssoId', flex: 1, hideable: false},
{header: 'SSO_TYPE', dataIndex: 'ssoType', flex: 1, hidden: true, hideable: false},
{header: 'GEO_UNIT_PURPOSE', dataIndex: 'geoUnitPurpose', flex: 1, hideable: false},
{header: 'GEO_UNIT_TYPE', dataIndex: 'geoUnitType', flex: 1, hideable: false},
{header: 'GEO_UNIT_VALUE', dataIndex: 'geoUnitValue', flex: 1, editor: 'textfield', hideable: false},
{header: 'GS_DATA_SOURCE_ID', dataIndex: 'gsDataSourceId', flex: 1, hidden: true, hideable: false},
{header: 'START_DATE', dataIndex: 'startDate', flex: 1, hidden: true, hideable: false},
{header: 'END_DATE', dataIndex: 'endDate', flex: 1, hidden: true, hideable: false},
{header: 'UPDATE_DATE', dataIndex: 'updateDate', flex: 1, hidden: true, hideable: false},
{header: 'UPDATE_ID', dataIndex: 'updateId', flex: 1, hidden: true, hideable: false},
{header: 'TAX_ID_TYPE', dataIndex: 'taxIdType', flex: 1, editor: 'textfield', hideable: false},
{header: 'TAX_ID', dataIndex: 'taxId', flex: 1, editor: 'textfield', hideable: false},
{header: 'TRANSACTION_TYPE', dataIndex: 'transactionType', flex: 1, hidden: true, hideable: false},
{header: 'DELETE', dataIndex: 'deleteRow', xtype: 'checkcolumn', width: 80, editor: 'checkbox', sortable: false, hideable: false}
];
this.callParent(arguments);
}
});
- Store and Proxy
Ext.define('DMT.store.FakeData', {
extend: 'Ext.data.Store',
model: 'DMT.model.PersonGeoUnitModel',
alias : 'widget.fakeDataStore',
proxy: {
type: 'ajax',
url: '/DMT/index.html',
reader: {
type: 'json',
root: 'data',
idProperty: 'id'
},
writer: {
type: 'json',
root: 'data',
encode: true,
writeAllFields: true
}
},
data: [
{ssoId: 'abc', geoUnitPurpose: 'LICENSE', geoUnitType: 'COUNTRY', geoUnitValue: 'HK', taxIdType: 'ANLLICID',
taxId: 'ABCD123'},
{ssoId: 'someone_else', geoUnitPurpose: 'LICENSE', geoUnitType: 'COUNTRY', geoUnitValue: 'HK', taxIdType: 'ANLLICID',
taxId: 'ABCD456'}
]
});