我正在将数据表转换为Json并将其设置为jqgrid,但它不显示数据
JAVA脚本
$(function(){ $( “#电网”)。jqGrid的({ url:“/ Approval / Home1”, 数据类型:'json', mtype:'GET', colNames:['DayofMonth','DayofWeek','InTime','OutTime','Status'], colModel:[
function dynamicTypeList() {
selItem = $("#Item_Number").val();
console.log(selItem);
$.ajax({
url: '@Url.Action("", "api/types/" + selItem)',
success: function (data) {
$("#Type_Id").empty();
$("#Name_Id").empty();
$("#Type_Id").append("<option value>Select Type (NEW)</option>");
$("#Name_Id").append("<option value>Select Name (NEW)</option>");
for (var i in data) {
$("#Type_Id").append("<option value='" + (i + 1) + "'>" + $(data)[i] + "</option>");
}
}
});
};
});
这是来源
{ name: 'DayofMonth', index: 'DayofMonth', editable: true },
{ name: 'DayofWeek', index: 'DayofWeek', editable: true },
{ name: 'InTime', index: 'InTime', editable: true, formatter: 'date', formatoptions: { newformat: "H:i " }, resizable: false },
{ name: 'OutTime', index: 'OutTime', editable: true, formatter: 'date', formatoptions: { newformat: "H:i " }, resizable: false },
{ key: false, name: 'Status', index: 'Status', editable: true }],
pager: jQuery('#pager'),
rowNum: 31,
loadonce: true,
height: '100%',
loadonce:true,
width: '100%',
viewrecords: true,
caption: 'Employee Monthly Data',
emptyrecords: 'No records to display',
jsonReader: {
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: false,
Id: "0"
},
autowidth: true,
autoheight: true,
multiselect: false
}).navGrid('#pager', {
edit: false, add: false, del: false, search: false, refresh: true
}).navButtonAdd('#pager', {
caption: "Edit",
onClickButton: function () {
var mygrid = $("#grid"), cellRowId = mygrid.jqGrid("getGridParam", "selrow"), cellValue = mygrid.jqGrid("getCell", cellRowId, "EmployeeCODE")
var div = $("#popup");
div.load("/Definations/delCompany?id=" + cellValue, function () {
div.dialog({
modal: true,
width: 300,
height: 350,
title: "Change Status.",
resizable: false
});
});
},
position: "last"
});
这是JSon Part
if (final.Rows.Count > 0)
{
JSONString.Append("[");
for (int i = 0; i < final.Rows.Count; i++)
{
JSONString.Append('{');
for (int j = 0; j < final.Columns.Count; j++)
{
if (j < final.Columns.Count - 1)
{
JSONString.Append( final.Columns[j].ColumnName.ToString() + "=" + final.Rows[i][j].ToString() + ",");
}
else if (j == final.Columns.Count - 1)
{
JSONString.Append( final.Columns[j].ColumnName.ToString() + "=" + final.Rows[i][j].ToString() );
}
}
if (i == final.Rows.Count - 1)
{
JSONString.Append('}');
}
else
{
JSONString.Append("}^");
}
}
JSONString.Append("]");
}
return JSONString.ToString();