Model view controller jqgrid如何动态创建列
我试图在mvc中实现一个jquery,这里有一些教程,但是我不希望jquery中的列被硬编码(或者事实上任何需要硬编码的东西),这是应该在控制器中的逻辑 所以…看看下面的代码,你会看到一个colNames:,和colModel:我如何编写它们,这样我就可以在一个模型中循环,为每个列项向网格中添加一列?实际上,我最终想要的是一个通用的jqGrid语句,唯一需要更改的是控制器中的代码Model view controller jqgrid如何动态创建列,model-view-controller,jqgrid,Model View Controller,Jqgrid,我试图在mvc中实现一个jquery,这里有一些教程,但是我不希望jquery中的列被硬编码(或者事实上任何需要硬编码的东西),这是应该在控制器中的逻辑 所以…看看下面的代码,你会看到一个colNames:,和colModel:我如何编写它们,这样我就可以在一个模型中循环,为每个列项向网格中添加一列?实际上,我最终想要的是一个通用的jqGrid语句,唯一需要更改的是控制器中的代码 Query("#list").jqGrid({ url: '/Home/GetMovieData/',
Query("#list").jqGrid({
url: '/Home/GetMovieData/',
datatype: 'json',
mtype: 'GET',
colNames: ['id', 'Movie Name', 'Directed By', 'Release Date', 'IMDB Rating', 'Plot', 'ImageURL'],
colModel: [
**{ name: 'id', index: 'Id', width: 55, sortable: false, hidden: true },
{ name: 'Movie Name', index: 'Name', width: 250 },
{ name: 'Directed By', index: 'Director', width: 250, align: 'right' },
{ name: 'Release Date', index: 'ReleaseDate', width: 100, align: 'right' },
{ name: 'IMDB Rating', index: 'IMDBUserRating', width: 100, align: 'right' },
{ name: 'Plot', index: 'Plot', width: 55, hidden: true },
{ name: 'ImageURL', index: 'ImageURL', width: 55, hidden: true}],**
pager: jQuery('#pager'),
rowNum: 5,
rowList: [5, 10, 20],
sortname: 'id',
sortorder: "desc",
height: '100%',
width: '100%',
viewrecords: true,
imgpath: '/Content/jqGridCss/redmond/images',
caption: 'Movies from 2008'
});
如果还有人在找它。 查看博客帖子