Suryacorner / flexigrid

Automatically exported from code.google.com/p/flexigrid
0 stars 0 forks source link

Incorrect population summary #117

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
The population order of the field data does not match column specification. The 
values does not get populated based on the column name, but in the order they 
are available in the JSON data.

I have following colModel:
            colModel : [
            {
                display: 'Id',
                name : 'id',
                width : 50,
                sortable : true,
                align: 'left',
                hide : true
            },
            {
                display: 'Name',
                name : 'name',
                width : 150,
                sortable : true,
                align: 'left'
            },
            {
                display: 'Account Number',
                name : 'accountNumber',
                width : 100,
                sortable : true,
                align: 'left'
            },
            {
                display: 'Bank IFSC Code',
                name : 'bankIFSCCode',
                width : 100,
                sortable : true,
                align: 'left'
            },
            {
                display: 'Request URL',
                name : 'requestUrl',
                width : 200,
                sortable : false,
                align: 'left'
            },
            {
                display: 'Response URL',
                name : 'responseUrl',
                width : 200,
                sortable : false,
                align: 'left'
            },
        ]

Here is my JSON output.
{"total":"1","pageCount":1,"requestStatus":"Success","page":0,"object":[{"id":1,
"name":"Pringoo.com","requestUrl":"https://www.pringoo.com","responseUrl":"https
://www.responseurl.pringoo.com/","accountNumber":"B1000","bankIFSCode":"SBI0001"
,"totalCount":"1"}]}

In the Account Number and Bank IFSC Column, the values populated are the 
Request URL and Response URL respectively. I changed the column locations in my 
colModel to make it work right for the time being.

It would be better if the population logic looks at the colModel specification 
and populates the data accordingly.

I am using the Flexigrid v1.1 with Jquery 1.5. Browser - Firefox on Ubuntu 
Maverick Meerkat x64.

Original issue reported on code.google.com by just...@gmail.com on 18 Mar 2012 at 5:20

GoogleCodeExporter commented 8 years ago
Adding to that, I have a preProcess method. Here is the specification for the 
same.

preProcess : function (json) {

            var results = new Array();
            jQuery.each(json.object, function() {

                var row = {};
                var cell = new Array();

                jQuery.each(this, function(k, v) {

                    if (k == "requestUrl" && v == "") {
                        cell.push("NA");
                    } else {
                        cell[k] = v;
                        cell.push(this);
                    }
                });

                row["cell"] = cell;
                results.push(row);
            });

            return {
                rows : results,
                page : json.pageCount,
                total : json.total
            };
        }

Original comment by just...@gmail.com on 18 Mar 2012 at 5:51

GoogleCodeExporter commented 8 years ago
I was able to resolve the issue. The condition check at Line #357 seemed to be 
wrong for my case.

Here is what I changed to make it use the colModel instead of index based 
population of cell. This section of code is in addData method.

                                        $('thead tr:first th', g.hDiv).each( //add cell
                            function () {
                                var td = document.createElement('td');
                                var idx = $(this).attr('axis').substr(3);
                                td.align = this.align;

                                // If the json elements aren't named (which is typical), use numeric order
                                if (typeof row.cell[idx] == "undefined") {
                                    td.innerHTML = (row.cell[idx] != null) ? row.cell[idx] : '';//null-check for Opera-browser
                                } else {
                                    td.innerHTML = row.cell[p.colModel[idx].name];
                                }

                                $(td).attr('abbr', $(this).attr('abbr'));
                                $(tr).append(td);
                                td = null;
                            }
                        );

Original comment by just...@gmail.com on 18 Mar 2012 at 5:54

GoogleCodeExporter commented 8 years ago
I too have the same problem . I want to display the JSON datas returned using 
'names' because i don't to display every fields displayed in the JSON.

Original comment by stylishr...@gmail.com on 28 Mar 2012 at 10:47

GoogleCodeExporter commented 8 years ago
I would be grateful if you show the format of JSON data returned in comment2 
because i am having the same problem. Hope ! solution works for me because i 
have been stuck because of this problem.

Thanks in advance 

Original comment by stylishr...@gmail.com on 28 Mar 2012 at 10:50

GoogleCodeExporter commented 8 years ago
I have already provided the solution which is working for my case above. See if 
that works for you too.

Original comment by just...@gmail.com on 28 Mar 2012 at 10:50

GoogleCodeExporter commented 8 years ago
The JSON format is given in Comment #1 and the Column Model used is available 
in Comment #2.

Original comment by just...@gmail.com on 28 Mar 2012 at 10:53

GoogleCodeExporter commented 8 years ago
{
                display: 'Bank IFSC Code',
                name : 'bankIFSCCode',
                width : 100,
                sortable : true,
                align: 'left'
            },
Check this code again, If you want easy API solutions for IFSC code web 
application
try http://www.bankswiftifsccode.com

Original comment by howtorea...@gmail.com on 31 Oct 2013 at 1:07