Author Topic: pqgrid.min.js:20 Uncaught TypeError: n.findIndex is not a function  (Read 2973 times)

edasilv

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 13
    • View Profile
Hi,

I am trying to populate my grid with remote data and I am getting a strange error like the following:

pqgrid.min.js:20 Uncaught TypeError: n.findIndex is not a function
    at pq.cRenderBody.init (pqgrid.min.js:20)
    at t.paramquery.cRefresh.refresh (pqgrid.min.js:12)
    at $.<computed>.<computed>.a.refresh (pqgrid.min.js:10)
    at $.<computed>.<computed>.a.refreshView (pqgrid.min.js:10)
    at $.<computed>.<computed>.i._onDataAvailable (pqgrid.min.js:12)
    at Object.callback (pqgrid.min.js:10)
    at $.<computed>.<computed>.a.onRemoteSuccess (pqgrid.min.js:10)
    at Object.success (pqgrid.min.js:10)
    at fire (jquery-3.4.1.js:3291)
    at Object.fireWith [as resolveWith] (jquery-3.4.1.js:3421)

Did someone experience something similar? Any suggestions?

In order to be sure about my data I've checked it is incorrect but using the same response data locally works fine but using the remote option does not.

The JS code is bellow:

$(document).ready(function(){

    var fileOption = $('#fileOption').data("file")
    var submission = $('#submissionId').data("submission")
    var result = $('#resultId').data("result")
 
    var urlResult = canonicalPhenodbUrl('/analyze/resultItem/' + fileOption + '/' + submission + '/' + result);

    var dataResponse = [
   {
      "1":"20472",
      "Yale New Genes":"rtyueiytegbe",
      "Gene Ontology":"http://genecards.org/cgi-bin/carddisp.pl?gene=IDH1&go_proc=1000&rf=/home/genecards/current/website/carddisp.pl#go_proc",
      "RefgeneExonLocation":"",
      "snp135_MultAl":"gdfhsdf",
      "hg19_esp6500siv2_aa":"lorem ipssunc",
      "Chromosome":"2"
   },
   {
      "1":"20472",
      "Yale New Genes":"vbbfbfgd",
      "Gene Ontology":"http://genecards.org/cgi-bin/carddisp.pl?gene=IDH1&go_proc=1000&rf=/home/genecards/current/website/carddisp.pl#go_proc",
      "RefgeneExonLocation":"fagutkjtuhrtg",
      "snp135_MultAl":"lorem ispndgf",
      "hg19_esp6500siv2_aa":"dfsadgaf",
      "Chromosome":"2"
   },
   {
      "1":"20472",
      "Yale New Genes":"98067985",
      "Gene Ontology":"http://genecards.org/cgi-bin/carddisp.pl?gene=IDH1&go_proc=1000&rf=/home/genecards/current/website/carddisp.pl#go_proc",
      "RefgeneExonLocation":"htjhyjdj",
      "snp135_MultAl":"lorem ispcdhjgfs",
      "hg19_esp6500siv2_aa":"tjdjtyjrj",
      "Chromosome":"2"
   }
]

    ////////////////////////////////////////////////
    //
    // Result Analysis Grid
    //
    var obj = {
        height:650, width: "flex", hwrap: false, wrap: false,
        scrollModel: { autoFit: false },
        title: "Analysis Result",
        //dataModel: {data: dataResponse},
        dataModel: {
            location: "remote",
            cache: true,
            url: urlResult,
            getData: function (response) {
                let dataResponse = JSON.stringify(response.data)
                console.log(dataResponse)
                return { data: dataResponse };
            }
        },
        flex: { one: true },
        collapsible: {on: false, toggle: true},
        resizable: true,
        menuIcon: true,
        menuUI:{
            tabs: ['hideCols']
        },
        pageModel: { type: "local", rPP: 25, rPPOptions: [10, 25, 50, 100, 500] },
        stateKeys: { groupModel: ['dataIndx', 'collapsed', 'grandSummary', 'nodeClose'] },
        toolbar: {
            cls: 'pq-toolbar-export',
            items: [
                {
                    type: 'button',
                    label: "Export",
                    icon: 'ui-icon-arrowthickstop-1-s',
                    listener: function () {
                            blob = this.exportData({
                                format: 'xlsx',
                                render: true
                            });
                        if(typeof blob === "string"){
                            blob = new Blob([blob]);
                        }

                        saveAs(blob, "analysisResult.xlsx");
                    }
                },
                {
                    type: 'button',
                    label: 'Save State',
                    listener: function () {
                        this.saveState();
                    }
                },
                {
                    type: 'button',
                    label: 'Restore State',
                    listener: function () {
                        //debugger;
                        this.loadState();
                    }
                },
                {
                    type: 'file',
                    attr: 'title="Open xlsx"',
                    attrFile: "accept='.xlsx,.csv'",
                    icon: 'ui-icon-folder-open',
                    label: ' Import File',
                    listener: function( evt ){
                        //import xlsx or csv file via HTML5 file input control.
                        var grid = this,
                            file = evt.target.files[0];//doesn't work in IE9.

                        if(file){
                            grid.showLoading();
                            //import first sheet of xlsx into workbook.
                            pq.excel.importXl( {file: file, sheets:
  • }, function( wb ){


                                //import workbook into grid.
                                grid.importWb({workbook: wb, extraRows: 10, extraCols: 10});
                                grid.hideLoading();
                            })
                        }
                    }
                },
            ]
        },
        create: function () {
            //restore state of grid.
            this.loadState({ refresh: false });
        },
    };

    // Analysis result grid
    var grid = pq.grid("#grid_result", obj)

    grid.on("onload", function () {
        this.saveState();
    })

});




paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: pqgrid.min.js:20 Uncaught TypeError: n.findIndex is not a function
« Reply #1 on: October 26, 2021, 02:12:55 pm »
When response is an array of rows as in your case, dataModel.getData callback is supposed to be this.

Code: [Select]
getData: function (response) {
     return { data: response };
}
« Last Edit: October 26, 2021, 08:51:33 pm by paramvir »

edasilv

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: pqgrid.min.js:20 Uncaught TypeError: n.findIndex is not a function
« Reply #2 on: October 26, 2021, 09:30:01 pm »
The data response listed above is for local use.
I've checked that before sending a message.
I did not list the response for remote use, but it needs the response.data (using console log prints correctly the answer) and as I said I get the error shown above.
Any suggestion?


Remote response:
{ data: [{
1: "20472",
Yale New Genes: "",
Gene Ontology: "http://genecards.org/cgi-bin/carddisp.pl?gene=IDH1&go_proc=1000&rf=/home/genecards/current/website/carddisp.pl#go_proc",
RefgeneExonLocation: "",
snp135_MultAl: "",
hg19_esp6500siv2_aa: "",
Chromosome: "2"
},
{
1: "20472",
Yale New Genes: "",
Gene Ontology: "http://genecards.org/cgi-bin/carddisp.pl?gene=IDH1&go_proc=1000&rf=/home/genecards/current/website/carddisp.pl#go_proc",
RefgeneExonLocation: "",
snp135_MultAl: "",
hg19_esp6500siv2_aa: "",
Chromosome: "2"
},
{
1: "20472",
Yale New Genes: "",
Gene Ontology: "http://genecards.org/cgi-bin/carddisp.pl?gene=IDH1&go_proc=1000&rf=/home/genecards/current/website/carddisp.pl#go_proc",
RefgeneExonLocation: "",
snp135_MultAl: "",
hg19_esp6500siv2_aa: "",
Chromosome: "2"
}]}

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: pqgrid.min.js:20 Uncaught TypeError: n.findIndex is not a function
« Reply #3 on: October 26, 2021, 09:35:57 pm »
In that case:

Code: [Select]
getData: function (response) {
     return { data: response.data };
}

edasilv

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: pqgrid.min.js:20 Uncaught TypeError: n.findIndex is not a function
« Reply #4 on: October 26, 2021, 10:00:22 pm »
Thank you for your quick response but I am getting the same error:
It was done as you suggested and the response is coming correctly because is logging as expected but the error keeps going on.

My data model is like the following:

175         dataModel: {
176             location: "remote",
177             cache: true,
178             url: urlResult,
179             getData: function (response) {
180                 console.log('logging response.data' + JSON.stringify(response.data))
181                 return { data: JSON.stringify(response.data) };
182             }
183         },


Any suggestion? Please help :) I have no idea to save the problem!!

My remote response:
{
data: [
{
1: "20472",
Yale New Genes: "",
Gene Ontology: "http://genecards.org/cgi-bin/carddisp.pl?gene=IDH1&go_proc=1000&rf=/home/genecards/current/website/carddisp.pl#go_proc",
RefgeneExonLocation: "",
snp135_MultAl: "",
hg19_esp6500siv2_aa: "",
EnsgeneExonFunction: "",
snp135_Frequency: "",
Parents: "",
KnownGeneExonFunction: "",
snp137_common_no_known_medical_impact: "",
Approved Symbol: "IDH1",
Gerp++elem_Pvalue: "",
Interactions: "",
Afalt_1000g2015aug_afr: "",
Hopkins Samples (SNV): "",
OMIM: "https://omim.org/entry/147700",
QualityRMS: "",
ValidForAnnovar: "1",
Hopkins Samples (Indel): "",
RefgeneGeneLocation: "intronic",
ExAC03: "",
ExAC03_EAS: "",
CADD Score: "",
tfbsConsSites: "",
segdup: "",
band: "2q34",
ExAC_r03_pLI: "Name=0.001453708",
Score_Ljb_lrt: "",
CCDS Intolerance Percentile: "55.44939844",
Score_Ljb_mt: "",
OMIM Inheritance: "",
snp137_common: "",
ExAC03_NFE: "",
500 Genes: "",
Score_Ljb_phylop: "",
Mouse Model: "Electrophoretic variation has been shown in tissues of liver, kidney, spleen and muscle. Strains C57BL/6, C3H/He carry the a allele; DBA/2 carries the b allele; M.m. castaneus and M.m. molossinus carry the c allele; the d allele is found at low frequencyin M. m. molossinus in Japan.",
snp132: "",
UW New Genes: "",
AFalt_hg19_cg69: "",
snp137_all: "",
Genotype: "hom",
CCDS Intolerance Score: "0.018483465",
Afalt_1000g2015aug_amr: "",
evofold: "",
KnownGeneGeneName: "IDH1",
ClinVar: "",
VEST_Score: "",
ExAC03_SAS: "",
Status / Expressed Allele: "",
OMIM Phenotypes: "{Glioma, susceptibility to, somatic}",
ExAC03_AMR: "",
snp135_ClinAssoID: "",
Score_Ljb_All: "",
Interaction: "AADAT, ABCF2, ACACB, ACO1, ACO2, ADSL, ALDH5A1, AMD1, ASL, ASS1, CEP57L1, DDA1, DDO, ELAVL1, FH, GLUD1, GLUD2, GMPPB, GOT1, GOT2, HAAO, HSPA5, IDH1, IDH2, IDH3A, IDH3B, IDH3G, IL4I1, MDH2, MTG1, MTHFR, NAGS, NIT2, OGDHL, OTC, PABPC1, PC, PIK3C2A, PKLR, PKM, PRKAG2, PSAT1, PSMD14, RIOK2, RPL10A, RPL4, RPS3A, RPS8, SRR, SUMO4, TARS, TP53I3, TRAPPC3, UBA5, UBA52, UBC, USP7, VAMP7, YWHAZ, ZHX1",
ExAC03_Global: "",
Afalt_1000g2015aug_all: "",
KnownGeneGeneLocation: "intronic",
PubMed: "https://www.ncbi.nlm.nih.gov/pubmed?term=IDH1",
ExAC03_FIN: "",
snp135_Allele: "",
omimgene: "Name=147700",
cosmic68wgs: "",
Score_Ljb_pp2hdiv: "",
Afalt_1000g2015aug_eas: "",
wgEncodeRegTfbsClusteredV3_Score: "",
Gerp++gt2: "",
SiftScore: "",
AFalt_hg19_cg46: "",
hg19_esp6500siv2_all: "",
StartPosition: "209101907",
RefgeneGeneName: "IDH1",
ExAC03_AFR: "",
EnsgeneGeneLocation: "intronic",
snp135_Common: "",
CADDgt20: "",
EndPosition: "209101907",
mce46way: "",
Score_Ljb_pp2hvar: "",
gnomAD_genome_freq: "",
HGMD_2017.2: "",
mirna: "",
wgEncodeRegDnaseClusteredV3_Score: "",
TotalDepth: "50",
UniProt: "http://www.uniprot.org/uniprot/O75874",
Score_Ljb_gerp++: "",
AlternativeAllele: "-",
Expression: "Adipose tissue / Adrenal / Bone marrow / Brain / Breast / Cartilage / Cervix / Colon / Eye / Gi tract / Head n neck / Kidney / Liver / Lung / Nervous / Ovary / Pancreas / Peripheral nerv / Pituitary gland / Placenta / Prostate / Retina / Skin / Spleen / Stomach / Testis / Uterus / Vascular",
gwascatalog: "",
Mammalian Phenotype: "http://www.informatics.jax.org/batch/summary?ids=IDH1&association=MP",
cosmic70: "",
snp129: "",
snp126: "",
OMIM Matching Phenotypes: "",
Afalt_1000g2015aug_sas: "",
fathmm_score: "",
RefgeneExonFunction: "",
EnsgeneExonLocation: "",
Kaviar_AF: "",
Hopkins Total Allele Count (Indel): "46_4598_6",
wgEncodeBroadHmmGm12878HMM_ChromatinStateSegmentation: "Name=10_Txn_Elongation",
GWAS Catalog: "",
ExAC_r03_mis_z: "Name=0.100659045",
gme_AF: "",
Gerp++elem_RSscore: "",
ExAC03_OTH: "",
revel_score: "",
CIDRVar50Mb: "",
ClinVar Variant Classification: "",
vistaEnhancer_ID: "",
miRdSNP: "http://mirdsnp.ccr.buffalo.edu/search.php?filter_gene_name=IDH1",
snp138: "",
EnsgeneGeneName: "ENSG00000138413",
snp135: "",
snp137: "",
snp131: "",
ReferenceAllele: "A",
Hopkins Total Allele Count (SNV): "",
VariantType: "Indel",
KnownGeneExonLocation: "",
dgv: "Name=nsv834517,nsv584297,nsv525747",
WG_GWAVA_score: "",
gnomAD_exome_freq: "",
Afalt_1000g2015aug_eur: "",
snp135_ClinAssoSubmit: "",
VISTA Enhancer: "",
ExAC_r03_gene: "Name=IDH1",
CIDRVar51Mb: "",
WG_EIGEN_score: "",
TraP: "",
hg19_esp6500siv2_ea: "",
simpleRepeat: "",
Quality: "2247559.94",
Chromosome: "2"
},
]
}

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: pqgrid.min.js:20 Uncaught TypeError: n.findIndex is not a function
« Reply #5 on: October 27, 2021, 09:54:08 am »
there is no JSON.stringify in my post. Please remove it.

Kindly share a jsfiddle if the issue still persists.

edasilv

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: pqgrid.min.js:20 Uncaught TypeError: n.findIndex is not a function
« Reply #6 on: November 06, 2021, 03:41:25 am »
Hi Paramvir,

here is the example. Please let me know any ideas to make this works!
https://jsfiddle.net/q15pd6g0/5/

Thanks

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: pqgrid.min.js:20 Uncaught TypeError: n.findIndex is not a function
« Reply #7 on: November 07, 2021, 10:40:55 am »
It's already working, I don't see any error thrown in your jsfiddle.

Please define colModel to display records in your grid.

edasilv

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: pqgrid.min.js:20 Uncaught TypeError: n.findIndex is not a function
« Reply #8 on: November 08, 2021, 07:36:37 pm »
No it's not. If you open the table,  you would see that rows and columns are not showing!

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: pqgrid.min.js:20 Uncaught TypeError: n.findIndex is not a function
« Reply #9 on: November 08, 2021, 08:56:36 pm »
Please define colModel as mentioned in my previous post.

Example: https://jsfiddle.net/Ldnw9p45/

edasilv

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: pqgrid.min.js:20 Uncaught TypeError: n.findIndex is not a function
« Reply #10 on: November 09, 2021, 12:27:57 am »
Exactly I needed colModel. Thanks for your message!
Can I get dynamic data to populate colModel?

I was looking on documentations that you suggested me in another question but I did not find it.
Thanks in advance!