Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
excel:true not working for me.
05/07/2010
10:20
Avatar
davykiash
Member
Members
Forum Posts: 6
Member Since:
05/02/2010
sp_UserOfflineSmall Offline

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?

05/07/2010
19:06
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

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/07/2010
22:04
Avatar
davykiash
Member
Members
Forum Posts: 6
Member Since:
05/02/2010
sp_UserOfflineSmall Offline

Just taken a look at your code.

The main issue is that when I simple add excel:true to my list of pager options the button does not appear.

This seems so obivous yet I can get that button to appear.

What could I be missing?

13/07/2010
05:58
Avatar
kuafusoft
Member
Members
Forum Posts: 27
Member Since:
31/12/2009
sp_UserOfflineSmall Offline

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';
}
}});

13/07/2010
08:45
Avatar
davykiash
Member
Members
Forum Posts: 6
Member Since:
05/02/2010
sp_UserOfflineSmall Offline

Hi

After playing around with the code this is what finally worked for me.

<input id="export-button" type="button"
    value="Export to CSV/Excel"
    title="Export Values to CSV or Excel"
    style="cursor: pointer;"/>

$('#export-button').click(function(){
            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

$file="income_transactions.csv";
            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.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
38 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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information