我似乎无法弄清楚如何根据 URL 中的参数中的 Id 加载 jqGrid。基本上我有地址 \Locations\Departmetn?LocationId=1 现在我想根据位置 ID 加载网格。网格只是使用地址 \Locations\GetDepartments 让控制器将数据作为 jSonResult 返回,这一切正常,我只是不知道如何/是否可以将位置 ID 发送到该 URL \Locations\GetDepartments
$(function () {
$.widget('qs.department_page', {
_create: function () {
var self = this;
this.scroll_to_end = false;
var LocId = 1; //hardcoded for the test
// get my child dom elements
this.department_pager = $("#department_pager");
// set up the grid and pager
this.department_grid = $("#department_grid").jqGrid(
{
url: "/Location/GetDepartments/",
datatype: "json",
mtype: "POST",
height: 300,
hidegrid: false,
colNames: ['Name', 'Site Num', 'Description', 'ABN'],
colModel: [
{ name: 'Name', index: 'Name', width: 200, align: "left", sortable: false },
{ name: 'SiteNum', index: 'SiteNum', width: 100, align: "left", sortable: false },
{ name: 'Company', index: 'Company', width: 200, align: "left", sortable: false },
{ name: 'ABN', index: 'ABN', width: 200, align: "left", sortable: false }
],
caption: "Departments",
pager: this.department_pager
})
.navGrid('#department_pager', {
addfunc: function () { self.onNewDepartment(); },
editfunc: function (val) { self.onEditDepartment(val); },
search: false,
refresh: false
},
{/*add*/
},
{/*edit*/
},
{ url: "/Location/DeleteDepartment" }
);
}