1

Good day, I'd like to get some inputs to where i might be doing wrong here.

I am using flexigrid (by Paul Marinas) and i keep getting this error below and the flexgrid does not display the records

(via firebug)
"row.cell is undefined [Break On This Error] if (typeof row.cell[idx] != "undefined") [flexigrid.js line 356]".
below is the json response from my class:

{"page":1,"rows":[{"approved":false,"companyname":"y","dateadded":1331606797706,"filename":"x111.txt","isdone":false,"status":"0"},{"approved":false,"companyname":"x","dateadded":1331605479681,"filename":"z222.txt","isdone":false,"status":"0"}],"total":2}

here is the flexigrid instance:

                $('#fgrid').flexigrid({
                    url: '/doValid/isvalid',
                    method: 'GET',
                    dataType: 'json',
                    colModel : [

                        {display : 'Company Name', name : 'companyname', width : 200, sortable : true, align: 'left'},
                        {display : 'File Name', name : 'filename', width : 150, sortable : true, align: 'left'},
                        {display : 'Date Uploaded', name : 'dateadded', width : 150, sortable : true, align: 'left'},
                        {display : 'approved', name : 'approved', width : 50, sortable : true, align: 'left'},
                        {display : 'done', name : 'isdone', width : 50, sortable : true, align: 'left'},
                        {display : 'Status', name : 'status', width : 300, sortable : true, align: 'left'}
                    ],
                    preProcess: formatFlex,
                    sortname : 'companyname',
                    sortorder: 'asc',
                    useRp: true,
                    rp: 40,
                    usepager: true,
                    showTableToggleBtn : false,
                    singleSelect: true

                });



and here is the formatFlex function:

            function formatFlex(data) {
                var dlist = Array();
                $.each(data.rows, function(i,row){
                    var compname ="";
                    var flname="";
                    var dadded="";
                    var bapp=false;
                    var bisdone=false;
                    var sstat="";

                    $.each(row,function(i,v){
                        if(i == "companyname"){
                            compname = v;
                        } else if (i == "filename") {
                            flname = v;
                        } else if (i == "dateadded") {
                            dadded = v;
                        } else if (i == "approved") {
                            bapp = v;
                        } else if (i == "isdone") {
                            bisdone = v;
                        } else if (i == "status") {
                            sstat = v;
                        }
                    });

                    dlist.push({"companyname": compname, "filename": flname, "dateadded": dadded, "approved": bapp, "isdone": bisdone, "status": sstat});
                    //even done this format
                    //dlist.push({companyname: compname, filename: flname, dateadded: dadded, approved: bapp, isdone: bisdone, status: sstat});

                });
                //alert("page : " + data.page + ", total: " + data.total + ", rows: " + dlist);
                return {
                    page:  data.page,
                    total: data.total,
                    rows: dlist
                };
            }



Already followed tutorials and forums for this jquery plug-in but i still can't quite get it to work.
Any help in clarifying this error is highly appreciated.

Thank you..

Dc Apple
  • 33
  • 3
  • 9

1 Answers1

0

Your JSON Format is wrong, the expected JSON format of flexigrid is:

total: (no of rec),
page : (page no),
rows : [{cell: [ (col1 value) , (col2 value) ,.. ] },
        {cell: [ (col1 value) , (col2 value) ,.. ] }]

Check the below link

https://gist.github.com/390274

Nemoy
  • 3,347
  • 1
  • 15
  • 14
  • thanks for the response. The earlier response from the class is passed to the preProcess argument of the flexigrid. Formatting the response to the required format you mentioned. However i tried it again using what you mentioned but still no data was displayed. Thanks again.. – Dc Apple Mar 14 '12 at 04:43
  • {"page": 1,"total": 2,"rows":[{"approved":false,"companyname":"y","dateadded":1331606797706,"filename":"x111.txt","isdone":false,"status":"0"},{"approved":false,"companyname":"x","dateadded":1331605479681,"filename":"z222.txt","isdone":false,"status":"0"}]}

    managed to get the json format to this, but flexigrid is still with the same error.
    – Dc Apple Mar 14 '12 at 07:34
  • Ok now got it... i've been ignoring the cell parameter all this time... Thank you very much. – Dc Apple Mar 14 '12 at 07:55