PDA

View Full Version : Adding new records to a JsonStore to update a GridPanel



MrTim
15 Feb 2010, 4:28 AM
Hi there. I am trying to add new data to a jsonstore by using a Ext.data.Record. The problem i am having is that the data is being added to the store but my gridpanel is not updating with the changes. I have read that if the store is changed there are events that catch the update and automatically updated the store it is associated with.

I know that my store is getting the new records as i am using a listener in the store to count the number of new records that are added.

Please help


Fig 1 (NMFD.csv.FileUpload)
this is where i initally call for the response data. As you can see the Store is held in a different object (see fig 2)



var _btnSubmit = new Ext.Action({
text: 'Start Data Import',
myFormAction: this,
handler: function() {
_frm_FileUpload.getForm().submit({
url: _frm_FileUpload.url,
params: { 'cmd': 'upload', 'pType': _cmbPipeType.getValue() },
success: function(form, action) {
var mappings = new NMFD.csv.AttributeMappings({});
var aFields = action.result.fields.split(",");
var rec = new Ext.data.Record.create([{ name: 'name'}]);
for (var i = 0; i < aFields.length; i++) {
mappings._store_CSVAttributes.add(new rec({ name: aFields[i] }));

};
},
failure: function() { /* put exception code here */ }
});
}
});


Fig 2 (NMFD.csv.AttributeMappings)



this._store_CSVAttributes = new Ext.data.JsonStore({
//listeners: { 'add': function() { alert("hree"); } }
});

// ADD DB REFERENCE HERE TO GET ALL GRID DATA
this._grd_CSVAttributes = new Ext.grid.GridPanel({
baseCls: '',
border: true,
style: 'float:left;margin:10px 0px 0px 30px;',
ddGroup: 'gridDDSource',
width: 210,
columns: [{ id: 'name', header: 'CSV Attributes', width: 190, sortable: true, dataIndex: 'name'}],
store: this._store_CSVAttributes,
stripeRows: true,
enableDragDrop: true,
selModel: new Ext.grid.RowSelectionModel({ singleSelect: true })
});


as you can see, i am not requesting the data for the store but almost pushing it from the NMFD.csv.FileUpload Action