Forum


heHi
I have just added the option excel:true to my navigation options but the button is not appearing on my grid pager.
Am using the example http://www.trirand.com/blog/ph.....efault.php
$("#list").jqGrid('navGrid','#pager',
{add:true,addtext:'Add',edit:true,edittext:'Edit',del:true,deltext:'Delete',view:true,viewtext:'View',search:true,searchtext:'Search',
refresh:true,refreshtext:'Refresh',excel:true,exceltext:'Excel'},
{url:'<?php echo $this->baseUrl() ?>/incomedetails/edit',closeAfterEdit:'true'},
{url:'<?php echo $this->baseUrl() ?>/incomedetails/add',closeAfterAdd:'true'},
{url:'<?php echo $this->baseUrl() ?>/incomedetails/delete',closeAfterAdd:'true'}
);
What am I missing?
19:06

10/08/2009

Hi!
I don't really know this feature, but in the source of the example which you post there are following important part which you probably not use:
jQuery('#grid').jqGrid('navButtonAdd','#pager',
{caption:'',
title:'Export to Excel',
onClickButton : function(e) {
try {
jQuery("#grid").jqGrid('excelExport',{url:'grid.php'});
} catch (e) {
window.location= 'grid.php?oper=excel';
}
}
});
The code of excelExport function is in the grid.import.js. If you use minimized version of jqGrid you should don't forget to check the corresponding part (Import/Export) before downloading of jqGrid.
Best regards
Oleg
05:58

31/12/2009

I checked the source code of the example case and find that:
jQuery('#grid').jqGrid('navGrid','#pager',{"edit":false,"add":false,"del":false,"search":true,"refresh":true,"view":false,"excel":true},{"drag":true,"resize":true,"closeOnEscape":true,"dataheight":150,"mtype":"POST"},{"drag":true,"resize":true,"closeOnEscape":true,"dataheight":150,"mtype":"POST"},
{"mtype":"POST"},
{"drag":true,"closeAfterSearch":true,"multipleSearch":true},{"drag":true,"resize":true,"closeOnEscape":true,"dataheight":150});
jQuery('#grid').jqGrid('navButtonAdd','#pager',{caption:'',title:'Export to Excel',onClickButton : function(e){
try {
jQuery("#grid").jqGrid('excelExport',{url:'grid.php'});
} catch (e) {
window.location= 'grid.php?oper=excel';
}
}});
Hi
After playing around with the code this is what finally worked for me.
value="Export to CSV/Excel"
title="Export Values to CSV or Excel"
style="cursor: pointer;"/>
var postData = $("#list").jqGrid('getGridParam','postData');
var str='';
for(i in postData)
str+=i+"="+postData[i]+"&";
window.location.href=("<?php echo $this->baseUrl() ?>/user/listpayments?export=excel&"+
str + new Date().getTime());
});
At the server side
header("Content-Disposition: attachment; filename=" . urlencode($file));
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Description: File Transfer");
header("Content-type: application/csv");
header("Pragma: no-cache");
header("Expires: 0");
$this->_response->setBody($export);
It did the magic for me.
Most Users Ever Online: 715
Currently Online:
64 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66