Using JqxGrid's excel export 'exportview' method
I'm using jqxGrid's client-side excel export 'exportview' method. I don't want to display hidden columns, but 'exportview' method displays all datafields. (On the other hand, 'exportdata' method provides the column hiding feature.) Is there no way to hide columns using 'exportview' method? Where can I find the API documentations abot this method? You can view the code at the following link. When I open downloaded .xlsx file, it shows hidden "Price" column. And so on, 'exportdata' method has a problem as "the page as loaded over HTTPS, but requested an insecure HTTP"
by inee814
HTML
<script src="https://jqwidgets.com/public/jqwidgets/jqx-all.js"></script>
<link rel="stylesheet" href="https://jqwidgets.com/public/jqwidgets/styles/jqx.base.css">
<link rel="stylesheet" href="https://jqwidgets.com/public/jqwidgets/styles/jqx.energyblue.css">
<script src="https://jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/generatedata.js"></script>
<script src="https://jqwidgets.com/public/jqwidgets/jqxexport.js"></script>
<script src="https://www.jqwidgets.com/public/scripts/jszip.min.js"></script>
<div id='jqxWidget' style="font-size: 13px; font-family: Verdana; float: left;">
<div id="jqxgrid"></div>
<div style='margin-top: 20px;'>
<div style='float: left;'>
<input type="button" value="Export to Excel" id='excelExport' />
<input type="button" value="Export to Excel(.xlsx)" id='xlsxExport' />
</div>
</div>
</div>
JavaScript
var data = generatedata(5);
var source = {
localdata: data,
datatype: "array",
datafields: [{
name: 'firstname',
type: 'string'
}, {
name: 'lastname',
type: 'string'
}, {
name: 'productname',
type: 'string'
}, {
name: 'available',
type: 'bool'
}, {
name: 'price',
type: 'number'
}],
updaterow: function (rowid, rowdata) {
// synchronize with the server - send update command
}
};
var dataAdapter = new $.jqx.dataAdapter(source);
// initialize jqxGrid
$("#jqxgrid").jqxGrid({
width: 600,
height: 200,
source: dataAdapter,
theme: 'energyblue',
editable: true,
selectionmode: 'singlecell',
columns: [{
text: 'First Name',
columntype: 'textbox',
datafield: 'firstname',
width: 90
}, {
text: 'Last Name',
datafield: 'lastname',
columntype: 'textbox',
width: 90
}, {
text: 'Product',
datafield: 'productname',
width: 170,
}, {
text: 'In Stock',
datafield: 'available',
columntype: 'checkbox',
width: 125,
}, {
text: 'Price',
datafield: 'price',
cellsalign: 'right',
cellsformat: 'c2',
width: 100,
hidden: true,
}]
});
$("#excelExport").jqxButton({
theme: 'energyblue'
});
$("#xlsxExport").jqxButton({
theme: 'energyblue'
});
$("#excelExport").click(function () {
$("#jqxgrid").jqxGrid('exportdata', 'xls', 'jqxGrid');
});
$("#xlsxExport").click(function () {
$("#jqxgrid").jqxGrid('exportview', 'xlsx', 'jqxGrid');
});