Ich habe mehr als genug Forschung in diesem, aber immer noch ein Mysterium getan. Ich zog Tabellenschema vom Server, um Spalten zu erstellen (result.colNames
) und Modell (result.colModel
), die gut funktionieren.Load JQGRID auf AJAX Erfolg mit dynamischen Spalten und Modell
bei demselben Ergebnis, ziehe ich Tabellendaten (result.colD
), um bei Erfolg in JQgrid aufzufüllen.
Grid erstellt zwar Erfolg, aber Daten werden nicht geladen.
Hier sind der Code und die Screenshots.
Ich habe viel Zeit in diesem verbracht, dann Posten hier..Hope das wird hier gelöst werden.
$.ajax({
type: "GET",
url: "webapi/do/pullSchema/"+display,
data: "",
dataType: "json",
success: function(result)
{
colD = JSON.stringify(result.colData);
colN = result.colNames;
colM = result.colModel;
jQuery("#list").jqGrid({
data:JSON.parse(colD),datatype: "local",
colNames:colN, colModel :colM,
pager: jQuery('#pager'),
rowNum: 5,
rowList: [5, 10, 20, 50],
viewrecords: true,
caption: 'DAta from table',
loadtext:'Loading, please wait'});
},
error: function(x, e)
{
alert(x.readyState + " "+ x.status +" "+ e.msg);
}
});
unten Beispieldatensätze:
[dbname=null, tables=null, ColNames=[Plan_code, LOB],
colModel=[{name:'Plan_code',index:'Plan_code',width:255}, {name:'LOB',index:'LOB',width:255}], colData=[{LOB=N, Plan_code=C82ACC}, {LOB=P, Plan_code=C82ACC}, {LOB=B, Plan_code=C82ACC}, {LOB=I, Plan_code=C82ACC}, {LOB=I, Plan_code=C82IRA}, {LOB=R, Plan_code=C82IRA}]
Länge der Spalte <> MODEL => {name: "Plan_code", index: "Plan_code", Breite: 255}, {name: "LOB", index: "LOB", width : 255} JSONStringify => ["{Name: \" Plan_code \ ", Index: \" Plan_code \ ", Breite: 255}", "{Name: \" LOB \ ", Index: \" LOB \ ", Breite: 255} "] parseJSON => {name:" Plan_code“, index: "Plan_code", Breite: 255}, {name: "LOB", index: "LOB", Breite: 255} Spaltennamen Spalten => Plan_code, LOB JSON Stringify => ["Plan_code", "LOB"] parseJSON => Plan_code, LOB h ardcoding unten, funktioniert gut // colNames: ["Plan_code", "LOB"], // colModel: [{Name: "Plan_code", Index: "Plan_code", Breite: 255}, {Name: "LOB ", index:" LOB ", width: 255}], –
Entschuldigung, ich war mir nicht sicher, wie ich meine nächste große Erklärung posten sollte. –