简体   繁体   中英

data not displaying in JQgrid when using datatype:function?

Edit:

Okay I think it's because when I assign sumColumnModel to colModel sumColumnModel is empty because sumColumnModel is only non-empty within the success function. So is there any way I can get that variable out of the success function and use it in colModel?


I am using a function to get my data and I am getting the data out just fine. I get this JSON from data.d:

"{"Page":1,
"TotalPages":5.0,
"TotalRecords":122,
"ColumnModel": [
    {"name":"Description","sorttype":"string","align":"center"},
    {"name":"Matrix","sorttype":"string","align":"center"},
    {"name":"AvailableReports","sorttype":"string","align":"center","hidden":true},
    {"name":"Classification","sorttype":"string","align":"center","hidden":true}
], 
"Submissions":[
    {"DateSubmitted":"4/23/2014","DateSampled":null,"Matrix":"Sometype","Status":"Completed","SubmissionId":"001","Description":"description","Company":null,"Classification":null,"AvailableReports":7},
    {"DateSubmitted":"4/23/2014","DateSampled":null,"Matrix":"sometype","Status":"Completed","SubmissionId":"002","Description":"description","Company":null,"Classification":null,"AvailableReports":6}
    ]}"

I am currently using this jsonreader:

jsonReader: {
    repeatitems: false,
    root: function(obj) { return obj.Submissions; },
    page: function(obj) { return obj.Page; },
    total: function(obj) { return obj.TotalPages; },
    records:function(obj) { return obj.TotalRecords; },
}

I tired putting in just 'Submissions' for the value of root in jsonreader but that didnt do the trick.

My column model is being edited in the success part of my ajax function call to correctly display certain columns that is done like this.

myData.ColumnModel.splice(0, 0,
    { name: "DateSubmitted", label: "Date Submitted", sorttype: "date", align: "center"});
myData.ColumnModel.push(
    { name: "Status", sorttype: "string", align: "center" },
    { name: "SubmissionId", label:"Submission Id", sorttype: "string", align: "center" });
sumColumnModel = myData.ColumnModel;

then I pass sumColumn as the Column model for the grid.

colModel: sumColumnModel,

Any idea why the grid isn't being populated?

So I wound up just initializing the colModel and then adding/subtracting things from it based on a couple drop down menus. It would be nice to know if I could actually get the col model out of the datatype:function but at this point I've just worked around it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM