jQWidgets Forums

jQuery UI Widgets Forums Grid jqxGrid Export to Excel

This topic contains 2 replies, has 2 voices, and was last updated by  smithgr@jhmi.edu 7 years, 6 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • jqxGrid Export to Excel #95963

    smithgr@jhmi.edu
    Participant

    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>

    jqxGrid Export to Excel #95979

    Hristo
    Participant

    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 Hristov

    jQWidgets team
    http://www.jqwidgets.com

    jqxGrid Export to Excel #95980

    smithgr@jhmi.edu
    Participant

    It 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’ }
    ]
    };

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.