PDA

View Full Version : Grid reconfigure not mapping with the model



prasad01
15 Oct 2012, 12:09 AM
Hi,
I created dynamic grid in which I am able to save the grid state.But while retrieving the grid data with dynamic columns,the data is coming from the server.But it is not displaying in the grid.Below is the code which I am working.Please give me a suggestion for this.:-/




Ext.Ajax.request({
url : 'prepareGenericScreen',
params :{userId : '1',gridId : 'GLCODE_MASTER_GRID_ID',action : 'resetAction'},
success : function(response) {
var data=Ext.decode(response.responseText);

var winMain = me.ownerCt.ownerCt.ownerCt;

var grid = winMain.child('#masterGrid');
var columnModel = data.metaData.fields;

grid.reconfigure(grid.getStore(), columnModel);
});

mitchellsimoens
22 Oct 2012, 7:08 AM
You are doing an Ext.Ajax but does the store have data in it?

Peter Tierney
28 Nov 2012, 9:47 AM
My result is the same but my setup is different. I am wanting to change the store's model and the grid layout to handle multiple types of returned search results. The code snippet below from a controller, is what I currently have and everything works except the data doesn't display. One exception to this is the ID column; it displays and updates correctly but that is the only piece of data both models have in common.


I have confirmed that data is being returned correctly by not only the ID changing in the grid but by alerting from the store's onJsonstoreRefresh with
alert(store.model.getName() + "\n" + store.data.items[0].raw.listDesc);


listDesc will have data in one model and be undefined in another which is what I expected.


Any pointers would be appreciated.




var columns = [];


if (reqModel.table === 'message')
{
this.getSearchResultsStore().model = this.getMessageModel();
columns.push(
{ header: 'ID', dataIndex: 'id', xtype: 'numbercolumn' },
{ header: 'Subject', dataIndex: 'subject' },
{ header: 'Sent Date', dataIndex: 'sentDate', flex:1, xtype: 'datecolumn' }
);
}
else if (reqModel.table === 'campaign')
{
this.getSearchResultsStore().model = this.getCampaignModel();
columns.push(
{ header: 'ID', dataIndex: 'id', xtype: 'numbercolumn' },
{ header: 'Status', dataIndex: 'campaignStatus' },
{ header: 'Sender Email', dataIndex: 'senderAddress', flex:1 }
);
}




this.getGrid().reconfigure( this.getSearchResultsStore(), columns );
this.getSearchResultsStore().proxy.url = this.application.getServicesBaseUrl() + "/search/getResults?" + reqModel.getQueryString();
this.getSearchResultsStore().reload();

Peter Tierney
28 Nov 2012, 12:07 PM
Apparently, the problem has something to do with dynamically assigning the store:
this.getSearchResultsStore().model = this.getCampaignModel();
or
this.getSearchResultsStore().model = Ext.create(this.getCampaignModel());


If I change the store to have the model assigned to it in the static manner inside the store
requires: [
'NotifyUI.model.Campaign'
],
it works just fine.


Is the way I'm assigning the store's model incorrect or is this a better way to do this?

Peter Tierney
28 Nov 2012, 6:48 PM
Well I've come to the conclusion that either this can't be done or there is a bug with reseting a store's model on the fly. I have resorted to creating a store for each search result instance with the specific model and reconfiguring the grid with the new store on the fly. It works, but certainly not as elegant as I had hoped.