jQWidgets Forums
jQuery UI Widgets › Forums › Grid › jqxGrid Export to Excel
Tagged: #jqwidgets-grid, grid, Grid Export Excel, javascript grid, jquery grid
This topic contains 2 replies, has 2 voices, and was last updated by smithgr@jhmi.edu 7 years, 6 months ago.
-
AuthorjqxGrid Export to Excel Posts
-
The following displays correctly on the screen but the excel export converts “thisLane” from a number (1 or 2) to a date. Thanks.
$(document).ready(function() {
$(“#table”).jqxGrid(
{
altRows: true,
sortable: false,
editable: false,
selectionMode: ‘singleRow’,
width: 1050,
height: 500,
columns: [
{ text: ‘FCID’, dataField: ‘FCID’, width: 100, hidden: false },
{ text: ‘Lane’, dataField: ‘Lane’, width: 50, hidden: false },
{ text: ‘SampleID’, dataField: ‘SampleID’, width: 200, hidden: false },
{ text: ‘SampleRef’, dataField: ‘SampleRef’, width: 150, hidden: false},
{ text: ‘Index’, dataField: ‘Index’, width: 150 },
{ text: ‘Description’, dataField: ‘Description’, width: 100 },
{ text: ‘Control’, dataField: ‘Control’, width: 100 },
{ text: ‘Recipe’, dataField: ‘Recipe’, width: 100 },
{ text: ‘Operator’, dataField: ‘Operator’, width: 100 },
{ text: ‘SampleProject’, dataField: ‘SampleProject’, width: 150 },
]
});$(“#excelExport”).jqxButton();
$(“#excelExport”).click(function () {
$(“#table”).jqxGrid(‘exportdata’, ‘xls’, ‘CellflowExport’);
});var initTable = function() {
$.getJSON(“https://apps.onc.jhmi.edu/researchapps/nextgenlab2/loaders/loadSeqImporter.cfm?flowcellUID=<cfoutput>#flowcellUID#</cfoutput>”, function(jsonData) {
for(var i=0; i<jsonData.length; i++) {
var strArray = jsonData[i].LANE.split(‘,’);
for(var j = 0; j < strArray.length; j++) {
var theLane = strArray[j].toString();$(“#table”).jqxGrid(‘addRow’, null, {
FCID: jsonData[i].FCID,
Lane: theLane.toString(),
SampleID: jsonData[i].SAMPLEID,
SampleRef: jsonData[i].SAMPLEREF,
Index: jsonData[i].INDEX2,
Description: jsonData[i].DESCRIPTION,
Control: “N”,
Recipe: jsonData[i].RECIPE,
Operator: jsonData[i].OPERATOR,
SampleProject: “DefaultProject” }, ‘last’);}
}
});};
initTable();
});
</script>
Hello smithgr@jhmi.edu,
I tested this example and it seems to work fine.
https://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/dataexport.htm?light
You should try to implement source with DataAdapter (it could be with empty ‘localdata’) and described datafields need to be included in it.
There you should determine the type of each one datafield, for example about “Lane” to be of{ name: 'Lane', type: 'date' }
. For more information about available types, you could visit our API Documentation section.Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.comIt works. Thanks! I added
var data = [];
var source =
{
localdata: data,
datatype: “array”,
datafields:
[
{ name: ‘FCID’, type: ‘string’ },
{ name: ‘Lane’, type: ‘string’ },
{ name: ‘SampleID’, type: ‘string’ },
{ name: ‘SampleRef’, type: ‘string’ },
{ name: ‘Index’, type: ‘string’ },
{ name: ‘Description’, type: ‘string’ },
{ name: ‘Control’, type: ‘string’ },
{ name: ‘Recipe’, type: ‘string’ },
{ name: ‘Operator’, type: ‘string’ },
{ name: ‘SampleProject’, type: ‘string’ }
]
}; -
AuthorPosts
You must be logged in to reply to this topic.