View Full Version : How do you get all store parameters? (4.1)

28 Jun 2012, 1:32 AM
How I'll get all the parameters that will be send when store.load() is run? I mean, I will not run store.load() but I want to get all request parameters. How I'll do it? (This is a grid's store)

28 Jun 2012, 1:49 AM
Could you elaborate a little on what it is you're trying to do exactly? What's the underlying problem you're trying to solve?

28 Jun 2012, 1:51 AM
I'll use them to download Excel file.

28 Jun 2012, 2:17 AM
If I understand correctly, you have a grid and want to give your users the option to download it as a spreadsheet? To do this, you want to make an (almost) identical request to the server as the request used to load the grid's store.

This could prove quite tricky, especially if you're using filters that are added in beforeload. One way to do it would be to add a temporary beforeload listener that captures the parameters then cancels the load. However, it seems a little risky to rely on the order the beforeload listeners will fire.

Another way that might work is to pull a temporary switch on the store's proxy. Put in a custom proxy that captures the parameters then switch it back to the original proxy.

Will the store have already loaded using the same set of options? If it will, it might be possible to capture the options on that request with a suitable hook and then you've got them for the download request.

28 Jun 2012, 10:13 AM
Do you want to create a XLS from the store, or download an existing XLS based on params?


28 Jun 2012, 10:08 PM
Do you want to create a XLS from the store, or download an existing XLS based on params?

Scott.I want to download server side generated XLSX based on parameters.

29 Jun 2012, 5:17 AM
You should be able to use ajax to make a request to the server and return the file

method: 'POST',
url: 'index.php/table_export/export_table/',
params : {
report_name: employee_report_name,
report_table: 'viewEmployees',
report_param: employee_report_param,
report_order: sortOrder // compound string for JAVA parameter
success: function(xhr) {
// clear mask and display
window.open('xls/' + employee_report_name + '.xls');
failure: function() {
// clear mask
alert('AJAX ERROR: Unable to export report, please contact support');

// example server return

//create xls
$objWriter = IOFactory::createWriter($objPHPExcel, 'Excel5');

// Sending headers to force the user to download the file
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: inline;attachment;filename="'.$reports_array['report_name'].'.xls"');


echo "{success:true}"; // done.. return

Your server will of course, need to handle the parameters sent to find the file.


29 Jun 2012, 5:21 AM
Here is the solution

buttons : [
text : LANG.EXCEL__GETIR, // Getir
// href: '/application.php?way=departmanTan&case=fetchNew' + '&excel=1',
// hrefTarget: '_blank' // used in 4.1
handler: function() {
var form = Ext.fly('exportXLSForm');
var frm = document.createElement('form');
frm.id = 'exportXLSForm';
frm.name = 'excelForm'; // id
frm.className = 'x-hidden';
form = Ext.fly('exportXLSForm');

departments = grid.filters.getFilterData();
var department;
for (var i = 0, len = departments.length; i < len; i++) {
obj = departments[i];
for (var key in obj) {
if (key !== 'data' && obj.data) {
obj.data[key] = obj[key];
departments[i] = obj.data || obj;
// console.log(departments);
// console.log(grid);
tempFilter = {};
//bilmemne = JSON.stringify(tempFilter)
// console.log(grid.store.sorters.items[0]);
params = {};
params.filter = JSON.stringify(departments);
sorter = {};
sorter.property = grid.store.sorters.items[0].property;
sorter.direction = grid.store.sorters.items[0].direction;
tempJson = JSON.stringify(sorter);
params.sort = '[' + tempJson + ']';
params.excel = true;
url : '/application.php?way=departmanTan&case=fetchNew',
method : 'POST',
form : form,
params : params,
isUpload : true
text : LANG.CANCEL, // ?ptal
handler : function()
Especially the grid.filters.getFilterData() and
sorter.property = grid.store.sorters.items[0].property;
sorter.direction = grid.store.sorters.items[0].direction;