Jqgrid has recently been used for a demand. It was originally used smoothly, but after the demand changes, only some field names jqgrid will not display the data, and the background data will also be transmitted to the foreground, but I just don't want to show it to me. The meat in my mouth cannot be eaten, and it cannot be described as a pain point or a depressing feeling ...... I began to doubt myself.
Jquery ("# grid-table"). jqgrid ({URL: '<% = request. getcontextpath () %>/salesanalysis. do? Method = getintelligencesaletree ', postdata: getparam (), // parameter datatype: "JSON", jsonreader: {root: "data", // array or list data page: "page", // current page Total: "pages", // total page number records: "count", // total number of records repeatitems: false}, colnames: ['region', 'city', 'districts and counties ', 'customer name', 'initial stocks', 'purchase qty', 'sales qty ', 'end-of-period stocks'], colmodel: [{Name: 'prov _ name', index: 'prov _ name', sorttype: 'text'}, {Name: 'city _ name', index: 'city _ name' ,}, {Name: 'area _ name', index: 'area _ name' },{ name: 'client _ name', index: 'client _ name', summarytype: 'Count', summarytpl: '{0}'}, {Name: 'In in _ stock', index: 'In in _ stock', align: "Right", sorttype: 'number', formatter: 'number', summarytype: 'sum'}, {Name: 'Code _ purchase_count ', index: 'Code _ purchase_count ', align: "right", sorttype: 'number', formatter: 'number', summarytype: 'sum'}, {Name: 'Code _ sale_count ', index: 'Code _ sale_count ', align: "right", sorttype: 'number', formatter: 'number', summarytype: 'sum'}, {Name: 'End _ stock ', index: 'End _ stock', align: "right", sorttype: 'number', formatter: 'number', summarytype: 'sum'}], rownum: 10, rowlist: [10, 20, 30], height: 'auto', autowidth: True, pager: '# gridpager', sortname: 'prov _ name', viewrecords: True, sortorder: "DESC", caption: "smart sales Tree", grouping: True, groupingview: {groupfield: ['prov _ name', 'city _ name ', 'area _ name'], // group field groupcolumnshow: [true, false, false], // whether to hide the group field grouptext: ['<B> {0} </B>'], groupcollapse: false, grouporder: ['asc '], // group-based sorting groupsummary: [True], groupdatasorted: True, // whether the data in the group is sorted showsummaryonhide: false // whether the summary information is displayed at the bottom of the group and whether the following groups are hidden when the table is collapsed}, footerrow: false, userdataonfooter: false, gridcomplete: function () {var IDs =$ ("# grid-table "). jqgrid ("getdataids"); For (VAR I = 0; I <IDs. length; I ++) {var Cl = IDs [I]; // leave empty var city = ""; $ ("# grid-table "). jqgrid ("setrowdata", Cl, {prov_name: City}) ;}, loadcomplete: replacecss });
All kinds of attempts, including changing request methods and local JSON, are unsolvable and depressing. I was thinking about this problem over the weekend. Finally, on Monday morning, Google found that jqgrid had a strict validation of JSON data formats, including single quotes and double quotes. jqgrid requires double quotation marks. If you use single quotes, pay attention to them, however, I found double quotation marks.
So where is my problem?
I copied the JSON to the front-end from firebug and put it in the online JSON checking tool (http://www.bejson.com/index.php). The problem was found, the original field data is "Changqing district \ 0 \ 0", and \ 0 \ 0 \ 0 jqgrid cannot be displayed, OMG ...... my background data is all temporarily added for testing, so it's easy to remove \ 0 \ 0 from the database ......
Conclusion: 1. First, you must have sufficient confidence in the code you have written. This requires less detours when solving the problem.
2. Use tools to quickly narrow down the scope of the problem. For example, firebug knows that data is transmitted normally.
3. the temper of the technologies used should be maximized. Just like me. Of course, it is best to fully understand the API.
Non-display of jqgrid data