[英]Why JQGrid shows empty records in MVC 5?
I have a problem that JQGrid load the data but show empty records. 我有一个问题,即JQGrid加载数据但显示空记录。 This is my controller action method:
这是我的控制器操作方法:
public ActionResult Database(string server,string database, string username, string password)
{
UserAthentication U = new UserAthentication();
U.ServerName = server;
U.DatabaseName = database;
U.Username = username;
U.Password = password;
Database db = new Database();
var Names = db.GetDatabaseNames(U); //This method returns the string list and i debugged it it returns the data correctly.
var jsondata = new
{
total = 1,
page = 1,
records = 0,
rows = Names
};
return Json(jsondata, JsonRequestBehavior.AllowGet);
}
This is JQgrid code: 这是JQgrid代码:
$(document).ready(function () {
$('#b1').click(function () {
var server = $("#ServerName").val();
var database = $("#DatabaseName").val();
var username = $("#Username").val();
var password = $("#Password").val();
var URL = '/Home/Database?server=' + server+"&database="+database+"&username="+username+"&password="+password;
$("#Grid").jqGrid({
url: URL,
datatype: 'json',
colNames: ['Tables Name'],
colModel: [
{ name: 'TABLE_NAME', index: 'TABLE_NAME' },
],
jsonReader: {
root: 'rows',
page: 'page',
total: 'total',
records: 'records',
repeatitems: false
},
pager: $('#pager'),
rowNum: 10,
rowList: [10, 20, 30],
width: 600,
viewrecords: true,
emptyrecords: 'No records to display',
sortorder: "desc",
caption: 'Databases',
loadonce: false,
});
});
});
It shows the empty rows. 它显示了空行。 There are 4 rows that should show and it shows 4 empty rows
应该显示4行,并显示4空行
colModel: [
{ name: 'TABLE_NAME', index: 'TABLE_NAME' },
],
you do not use TABLE_NAME but instead you use columns name like this: 您不使用TABLE_NAME,而是使用这样的列名:
colModel: [
{ name: 'Column_NAME', index: 'Column_NAME' },
{ name: 'Column_NAME', index: 'Column_NAME' },
{ name: 'Column_NAME', index: 'Column_NAME' },
{ name: 'Column_NAME', index: 'Column_NAME' },
],
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.