<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
	<title>jQuery Grid Plugin - jqGrid - Topic: Export to EXCEL and PDF</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/export-to-excel-and-pdf</link>
	<description><![CDATA[Grid plugin]]></description>
	<generator>Simple:Press Version 5.7.5.3</generator>
	<atom:link href="http://www.trirand.com/blog/?page_id=393/help/export-to-excel-and-pdf/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>miki on Export to EXCEL and PDF</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/export-to-excel-and-pdf#p23327</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/export-to-excel-and-pdf#p23327</guid>
        	        	<description><![CDATA[<p>I am proviidng my controller code to populate the grid. I have not written any code to export in the controller. I am assuming that, JQGrid will do the export functionality. If not would you please provide me a link or&#160;if there is any code published already in this help forum in case if you know.</p>
</p>
<p>This is my controller code to populate the grid:</p>
</p>
<p>public virtual JsonResult GetJQGridJsonData(int page, int rows, string search, string sidx, string sord)<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; List&#60;Product&#62; jqData = new List&#60;Product&#62;();<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; jqData = Repository.GetProducts();</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; int pageSize = rows;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; int totalRecords = jqData.Count();</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; int totalPages;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (totalRecords &#62; 0)<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; else<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; totalPages = 0;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // if for some reasons the requested page is greater than the total set the requested page to total page <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (page &#62; totalPages) page = totalPages;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; //total &#8211; Total number of Pages.<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; //page &#8211; Current page Index.<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; //records &#8211; Total number of records in the rows group.<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; //rows &#8211; An array with the data plus an identifier.<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; //id &#8211; The unique row identifier, needs to be an int from what I have found.<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; //cell &#8211; An array of the data for the grid.<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var jsonData = new JqGridJsonData<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; total = totalPages,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; page = page,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; records = totalRecords,</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; rows = jqData.Select(vm =&#62;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; new JQGridRowJson<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; id = vm.ProductId.ToString(),<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; cell = new[]{</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; vm.ProductId.ToString(),<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; vm.ProductNumber,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; vm.Size,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; vm.ReleaseDate.ToShortDateString(),<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; vm.Amount.ToString(),<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; vm.Description,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }).ToArray()</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; };<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; //&#60;a href="http://www.pageresource.com/linkus.htm" /&#62; &#60;/a&#62; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return Json(jsonData, JsonRequestBehavior.AllowGet);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
]]></description>
        	        	<pubDate>Wed, 25 May 2011 20:47:25 +0300</pubDate>
        </item>
        <item>
        	<title>kobruleht on Export to EXCEL and PDF</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/export-to-excel-and-pdf#p23320</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/export-to-excel-and-pdf#p23320</guid>
        	        	<description><![CDATA[<p>Can you publish export controller code.</p>
]]></description>
        	        	<pubDate>Wed, 25 May 2011 19:14:21 +0300</pubDate>
        </item>
        <item>
        	<title>miki on Export to EXCEL and PDF</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/export-to-excel-and-pdf#p23319</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/export-to-excel-and-pdf#p23319</guid>
        	        	<description><![CDATA[<p>I am using jqgrid with MVC. I am trying to add export to excel functioanlity to the grid pager using a custom button add feature of jqgrid. Excel button is showing up in the pager. I have created a empty excel file and gave that URL.</p>
</p>
<p>When I click on excel button in the pager, excel is opening but jqgrid data is not exported. I think I am missing something or I am not using this feature correctly.</p>
</p>
<p>Could someone help on how to do export to excel (if possible PDF as well).</p>
<p>Your help is greatly appreciated.</p>
</p>
<p>Thanks</p>
<p>Miki</p>
<p>&#160;&#60;table id="list2"&#62;&#60;/table&#62;<br />&#60;div id="pager2"&#62;&#60;/div&#62;<br />&#60;a href="#" id="a1"&#62;Get data from selected row&#60;/a&#62;</p>
<p>&#60;script type="text/javascript"&#62;</p>
<p>&#160;&#160;&#160; jQuery("#list2").jqGrid({<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; url: &#39;/JsonProducts/GetJQGridJsonData/&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; datatype: "json",<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; colNames: [&#39;ProductId&#39;, &#39;ProductNumber&#39;, &#39;Size&#39;, &#39;ReleaseDate&#39;, &#39;Amount&#39;, &#39;Description&#39;,&#39;fileAttached&#39;],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; colModel: [<br />&#160;&#160; &#160;&#160;{ name: &#39;ProductId&#39;, index: &#39;ProductId&#39;, width: 100, sortable: true, sorttype: "int" },<br />&#160;&#160; &#160;&#160;{ name: &#39;ProductNumber&#39;, index: &#39;ProductNumber&#39;, width: 100, sortable: true, sorttype: "text" },<br />&#160;&#160; &#160;&#160;{ name: &#39;Size&#39;, index: &#39;Size&#39;, width: 100, sortable: true, sorttype: "text" },<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; { name: &#39;ReleaseDate&#39;, index: &#39;ReleaseDate&#39;, width: 100, datefmt: "mm/dd/yyyy", sorttype: "date", sortable: true },<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; { name: &#39;Amount&#39;, index: &#39;Amount&#39;, width: 100, sortable: true, sorttype: "float" },<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name: &#39;Description&#39;, hidden: true, index: &#39;Description&#39;, width: 100, sortable: false, editable: true, editrules: { edithidden: true} },<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name: &#39;fileAttached&#39;, index: &#39;fileAttached&#39;, align: "center", width: 40 }<br />&#160;&#160; &#160;],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; rowNum: 20,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; rowList: [10, 20, 30],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; pager: &#39;#pager2&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; sortname: &#39;ProductId&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; viewrecords: true,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; sortorder: "desc",<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; caption: "Products List",<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; multiselect: true,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; width: 800,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; height: 600,<br />&#160;&#160;&#160;&#160;&#160;&#160; // toppager: true,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; loadonce: true, // to enable sorting on client side<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; sortable: true //to enable sorting <br />&#160;&#160;&#160; });<br />&#160;&#160;&#160; jQuery("#list2").jqGrid(&#39;navGrid&#39;, &#39;#pager2&#39;, { edit: false, add: false, del: false, view: true });<br />&#160;&#160;&#160; jQuery("#list2").jqGrid(&#39;filterToolbar&#39;, { stringResult: true, searchOnEnter: false });</p>
<p>&#160;&#160;&#160; jQuery("#list2").jqGrid(&#39;navButtonAdd&#39;, &#39;#pager2&#39;, {</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; caption: "Export to Excel",</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; onClickButton: function () {</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; jQuery("#list2").jqGrid(&#39;excelExport&#39;, { url: &#39;/Export/ExportExcel.xls&#39; });</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p>&#160;&#160;&#160; });<br />&#60;/script&#62;</p>
]]></description>
        	        	<pubDate>Wed, 25 May 2011 18:21:30 +0300</pubDate>
        </item>
</channel>
</rss>