Dec 15, 2011, 9:38 AM
Is the above code equivalent with the grid.store.getSortState, grid.getColumnModel().getColumnsBy and grid.getFilterPlugin()
I am using this old approach to get settings/options from the grid and your code is so much cleaner :-)
I am using this old approach to get settings/options from the grid and your code is so much cleaner :-)
var settings = {
sortState:{},
columns:[],
filter: []
};
// Get any custom sorting from the grid
settings.sortState = grid.store.getSortState() || {field:"", direction:""};
// Get column state from the grid
grid.getColumnModel().getColumnsBy( function(c) {
settings.columns.push(
{
id: c.id,
dataIndex: c.dataIndex,
columnWidth: c.columnWidth,
hidden: c.hidden,
locked: c.locked
}
);
}
);
// Any custom filters applied
if (grid.getFilterPlugin() != null) {
grid.getFilterPlugin().filters.each(function(f) {
if (f.active) {
settings.filter.push({ field: f.dataIndex, args: f.serialize() });
}
});
}
// Get which format to use for data export
if (format == 'sel')
{
switch (btnExport.activeItem.id)
{
case 'mnuExportToXLS':
format = 'xls';
break;
case 'mnuExportToXML':
format = 'xml';
break;
case 'mnuExportToCSV':
format = 'csv';
break;
case 'mnuExportToPDF':
format = 'pdf';
break;
default:
break;
}
}
// Use httphandler to download/get the export
window.location = 'genericGet.ashx' +
'?table=' + table +
'&format=' + format +
'&filter=' + txtFilter.getValue() +
'&settings=' + Ext.encode({settings:[settings]});
thanks /Peter