Oct 30, 2009, 5:46 PM
Bind existing Grid to Client-Side datasource
Is there a way to take an existing grid and (re)set its store to a store bound on the client-side?
I have the below - which works well for creating a grid as a new grid - but wanted to take an existing grid and reassign the myStore datasource below?
I have the below - which works well for creating a grid as a new grid - but wanted to take an existing grid and reassign the myStore datasource below?
var commentTable = myDetail[2];
var myStore = new Ext.data.SimpleStore({
fields: [
{ name: 'DateStamp' },
{ name: 'CommentsText', type: 'string' },
{ name: 'User', type: 'string' },
]
});
var record = null;
var values = {};
for (var row = 0; row < commentTable.length; row++) {
values = {};
values['DateStamp'] = commentTable[row].DateStamp;
values['CommentsText'] = commentTable[row].CommentsText;
values['User'] = commentTable[row].User;
record = new Ext.data.Record(values, 0);
myStore.insert(0, record);
}
myStore.load;
//gpComments.store = myStore;
//gpComments.load();
var grid = new Ext.grid.GridPanel({
store: myStore,
columns: [
{ id: 'company', header: 'Date', width: 115, sortable: true, dataIndex: 'DateStamp' },
{ id: 'comment', header: 'Comments', width: 75, sortable: true, dataIndex: 'CommentsText' },
{ header: 'User', width: 75, sortable: true, dataIndex: 'User', align: 'right' }
],
stripeRows: true,
autoExpandColumn: 'comment',
height: 350,
width: 500
});
// render the grid to the specified div in the page
grid.render('grid-example');