幾個小時前我遇到了這個問題,我無法繞過它。JqGrid不從asp.net加載數據mvc動作
我想實現JqGrid到我的ASP.NET MVC應用程序。我使用Phil Haack的blog post的例子。
我進口的js和css:
<link href="/Content/jquery-ui-1.8.5.custom.css" rel="stylesheet" type="text/css" />
<link href="/Content/ui.jgrid.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/Scripts/jquery-1.4.1.js"></script>
<script type="text/javascript" src="/Scripts/jquery-ui-1.8.5.custom.min.js"></script>
<script type="text/javascript" src="/Scripts/jquery.jqGrid.min.js" ></script>
<script type="text/javascript" src="/Scripts/grid.local-en.js" ></script>
我把這個代碼視圖:
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("#list").jqGrid({
url: '/Ticket/All/',
datatype: 'json',
mtype: 'GET',
colNames: ['Id', 'Hardware', 'Issue', 'IssueDetails', 'RequestedBy', 'AssignedTo', 'Priority', 'State'],
colModel: [
{ name: 'Id', index: 'Id', width: 40, align: 'left' },
{ name: 'Hardware', index: 'Hardware', width: 40, align: 'left' },
{ name: 'Issue', index: 'Issue', width: 200, align: 'left' },
{ name: 'IssueDetails', index: 'IssueDetails', width: 200, align: 'left' },
{ name: 'RequestedBy', index: 'RequestedBy', width: 40, align: 'left' },
{ name: 'AssignedTo', index: 'AssignedTo', width: 40, align: 'left' },
{ name: 'Priority', index: 'Priority', width: 40, align: 'left' },
{ name: 'State', index: 'State', width: 40, align: 'left'}],
pager: jQuery('#pager'),
rowNum: 10,
rowList: [5, 10, 20, 50],
sortname: 'Id',
sortorder: "desc",
viewrecords: true,
caption: 'My first grid'
});
});
</script>
<h2>My Grid Data</h2>
<table id="list" class="scroll" cellpadding="0" cellspacing="0"></table>
<div id="pager" class="scroll" style="text-align:center;"></div>
這裏是在票務控制我的測試動作:
public ActionResult All(string sidx, string sord, int page, int rows)
{
var jsonData = new
{
total = 1, // we'll implement later
page = page,
records = 3, // implement later
rows = new[]{
new {id = 1, cell = new[] {"1", "hard asdf", "issue adfds", "more issue", "someuser", "otheruser", "2", "Submitted"}},
new {id = 2, cell = new[] {"2", "hard asdf", "issue adfds", "more issue", "someuser", "otheruser", "2", "Submitted"}},
new {id = 3, cell = new[] {"3", "hard asdf", "issue adfds", "more issue", "someuser", "otheruser", "2", "Submitted"}}
}
};
return Json(jsonData);
}
在這那一刻,我可以看到空格子,但是整個頁面覆蓋着疊加層,我不能點擊任何東西(這可能是「加載」ov erlay)。
這裏有什麼問題?
使用Firebug(例如)並查看是否存在JavaScript錯誤或您的AJAX請求的外觀如何,是否存在錯誤以及您的所有操作是否完成。 – queen3 2010-10-27 15:21:13