我已经开始尝试学习 MVC 4 并进行了粗略的尝试。当 VS2010 处于调试模式时,我设法让 Flexigrid 在显示数据库表中的数据时工作,但是当我部署站点时,我的 flexigrid 根本不显示任何记录。据我所知,它根本没有击中控制器。我已经没有关于如何解决这个问题的想法了......
$('#MySkillList').flexigrid({
url: '/Home/ListMySkills',
dataType: 'json',
colModel: [
{
display: 'SkillName',
name: 'SkillName',
width: 180,
sortable: true,
align: 'left'
},{
display: 'SkillID',
name: 'SkillID',
width: 100,
sortable: true,
align: 'left',
},{
display: 'PersonID',
name: 'PersonID',
width: 100,
sortable: true,
align: 'left',
},{
display: 'Validated',
name: 'Validated',
width: 100,
sortable: true,
align: 'left'
}],
sortname: "SkillName",
sortorder: "asc",
usepager: true,
title: 'My Skills',
useRp: true,
rp: 15,
showTableToggleBtn: true,
width: 600,
height: 200
});
控制器
public ActionResult ListMySkills(FreeLancererSkills fModel)
{
string GUID = LoginGuid;
string SQL = "EXEC FreelancerSkills_Get '"+GUID+"'";
DBLayer DBL = new DBLayer();
DataSet DS = DBL.GetData(connString, SQL);
List<FreeLancererSkills> iList = new List<FreeLancererSkills>();
var model = new FreelancerSkillsCollection();
int i = 1;
foreach(DataRow DR in DS.Tables[0].Rows)
{
FreeLancererSkills iSkills = new FreeLancererSkills();
iSkills.LoginGuid = GUID;
iSkills.PersonID = DR["PersonID"].ToString();
iSkills.SkillID = DR["SkillID"].ToString();
iSkills.SkillName = DR["SkillName"].ToString();
iSkills.Validated = DR["Validated"].ToString();
iList.Add(iSkills);
i++;
}
TempData["LoginToken"] = GUID;
return JsonResult(iList.ToList(), 1, i);
}
private JsonResult JsonReturn(List<FreeLancererSkills> items, int page, int total)
{
return Json(
new
{page, total, rows = items.Select(x => new
{
id = x.SkillID,
// either use GetPropertyList(x) method to get all columns
cell = new object[] { x.SkillName, x.SkillID, x.PersonID, x.Validated }
})
}, JsonRequestBehavior.AllowGet);
}
希望有人能够帮助我弄清楚发生了什么。