在使用 Lib.Web.Mvc 3 中的帮助程序类时,我遇到了一个问题。
问题-
我将 jqGrid 的 hidden 属性设置为 true,以便在第一页加载时它不可见。但是当用户从列表中选择一个项目时,网格的隐藏属性设置为 false 并启动重新加载触发器。但由于某种原因,在选择项目并发生重新加载装配后,控制器操作永远不会被调用。我是 MVC 的新手,所以请原谅我的愚蠢问题。谢谢!
<div id="gridWrapper">
@{
var grid = new JqGridHelper<Configuration.Models.Post.ProfileModel>(
"Servers",
caption: "Servers List",
hidden: true,
hiddenEnabled: true,
dataType: JqGridDataTypes.Json,
methodType: JqGridMethodTypes.Post,
pager: true,
rowsNumber: 10,
sortingName: "Profile",
sortingOrder: JqGridSortingOrders.Asc,
url: Url.Action("GetServersWithSettings"),
editingUrl: Url.Action("Edit"),
loadComplete: "function (data) {var recs =
parseInt($(\"#Servers\").getGridParam(\"records\"),10);" +
"if (isNaN(recs) || recs == 0) {" +
"$(\"#gridWrapper\").hide();" +
"}" +
"else {$('#gridWrapper').show();" +
"}"+"}",
sortable: true
).Navigator(new JqGridNavigatorOptions
{
Add = true,
Delete = false,
//Edit = true,
View = false
})
.FilterToolbar(new JqGridFilterToolbarOptions
{
StringResult = true,
DefaultSearchOperator = JqGridSearchOperators.Cn,
AutoSearch = true,
SearchOnEnter = false,
});
@grid.GetHtml()
}
</div>
@section scripts {
<link href="@Url.Content("~/Content/themes/base/jquery-ui.css")" rel="stylesheet"
type="text/css" />
<link href="@Url.Content("~/Content/jquery.jqGrid/ui.jqgrid.css")" rel="stylesheet"
type="text/css" />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-
ui.css" />
<style>
#feedback { font-size: 1.4em; }
#selectable .ui-selecting { background: #FECA40; }
#selectable .ui-selected {background: #F39814;color: white; }
#selectable {list-style-type: none;margin: 0;padding: 0;width: 60%; }
#selectable li {margin: 3px;padding: 0.4em;font-size: 1.4em;height: 18px; }
</style>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="@Url.Content("~/Scripts/i18n/grid.locale-en.js")" type="text/javascript">
</script>
<script src="@Url.Content("~/Scripts/jquery.jqGrid.min.js")" type="text/javascript">
</script>
<script type="text/javascript">
$(document).ready(function() {
@grid.GetJavaScript();
})
</script>
<script type="text/javascript">
// callback function to bring a hidden box back
$(function() {
$("#selectable").selectable({
stop: function() {
$(".ui-selected", this).each(function() {
var url = 'Profile/GetServersWithSettings/?id=' +
$(this).attr('id');
$("#Servers").jqGrid('setGridParam', { url: url
}).trigger('reloadGrid');
});
}
});
});
</script>
}