jsGrid "exportData([options])" error Uncaught TypeError: Cannot read property 'apply' of undefined

246 views Asked by At

I try to export excel or csv from jsGrid. i just followed this documentation

my code example is below:

function initPhotoGrid(imageIds) {
    $("#photoGrid").jsGrid("destroy")
    $("#photoGrid").jsGrid({  
            width: "100%",  
            filtering: false,
            inserting: false,
            editing: false,
            sorting: true,
            paging: false,
            autoload: true,
            controller: {
                loadData: function (filter) {
                    var d = $.Deferred();
                    $.ajax({
                        url: `/api/ConstrInspInfo/inspImages?imageIds=${imageIds}`,
                        dataType: "json",
                        data: filter
                    }).done(function (response) {
                        d.resolve(response)
                    }).fail(err => {
                        alert("get intakeReport fail....plz try later")
                        console.log(err.msg)
                    })
                    return d.promise()
                }
            },
            fields: [
                { name: "ReportId", type: "text", visible: false },
                { name: "Addon", title: "time", type: "text"},
                { name: "FilePath", title: "photo", type: "text"},
                { name: "ImageDescription", title: "desc", type: "text"},
            ]
        })
}

the import data source are :

data = [{ ReportId: 64,FilePath: "/infodocs/database/TMS/Document/InspImage/ec39103f-8f96.pdf",Addon: "2021-04-29T13:17:44.8268244", ImageDescription: "test"}];

i use jsGrid exportData function like this

 var csv = $("#photoGrid").jsGrid("exportData", {
    type: "csv", //Only CSV supported
    subset: "visible", 
    delimiter: "|", 
    includeHeaders: true, 
    encapsulate: true, 
    newline: "\r\n",         
    filter: function (item) { return true },
});

and i got error code below:

Uncaught TypeError: Cannot read property 'apply' of undefined
    at HTMLDivElement.<anonymous> (jsgrid.js:1405)
    at Function.each (jquery.min.js:2)
    at S.fn.init.each (jquery.min.js:2)
    at S.fn.init.$.fn.jsGrid (jsgrid.js:1398)
    at <anonymous>:1:16(anonymous)

how can i fix this bug? plz help me~

0

There are 0 answers