mygrid = $("#list").jqGrid({
width: 800,
height: 450,
url: 'LoadActionSubmit/',
datatype: 'json',
mtype: 'POST',
pager: jQuery('#pager'),
rowNum: 20,
rowList: [20, 40, 60, 80],
sortname: 'Id',
sortorder: "desc",
viewrecords: true,
imgpath: '/scripts/themes/steel/images',
caption: '查询条件:',
recordtext: '条记录',
sortorder: "desc",
loadtext: 'loading....',
colNames: ['网吧名称', '活动日期', '活动开始时间', '活动结束时间', '包机数量', '活动费用', '删除'],
colModel: [{ name: 'netbarid', index: 'NETBARNAME', width: 160, align: 'center' },
{ name: 'barname', index: 'ACTIONDATE', width: 160, align: 'center', sorttype: "date" },
{ name: 'province', index: 'ACTIONBEGINTIME', width: 160, align: 'center' },
{ name: 'city', index: 'ACTIONENDTIME', width: 160, align: 'center' },
{ name: 'county', index: 'FLIGHTSNUMBER', width: 160, align: 'center' },
{ name: 'applicant', index: 'ACTIONFEES', width: 160, align: 'center' },
{ name: 'act', index: 'act', width: 160, align: 'center', sortable: false}],
loadComplete: function() {
// var sumrecords = $("#list").getGridParam("records");
// if (sumrecords != null) {
// $('#totalsum').text(sumrecords);
// }
var ids = jQuery("#list").getDataIDs();
for (var i = 0; i < ids.length; i++) {
var cl = ids[i];
se = "<input style='height:22px;width:20px;' type='button' value='S' onclick=jQuery('#list').saveRow(" + cl + "); />";
var menuDate = "对字段:的处理";
$("#list").setRowData(cl, { act: se});
}
},
onSelectRow: function(id) {
if (id && id !== lastsel3) {
jQuery('#list').restoreRow(lastsel3);
jQuery('#list').editRow(id, true, pickdates);
lastsel3 = id;
}
}
});
});
function pickdates(id) { jQuery("#" + id + "_sdate", "#rowed6").datepicker({ dateFormat: "yy-mm-dd" }); }
public ActionResult LoadActionSubmit(WModels.ActionCondition condition)
{
List<WModels.TgsActionSubmit> questions = new List<WModels.TgsActionSubmit>() {
new WModels.TgsActionSubmit()
{
NETBARNAME="春心荡漾",
ACTIONDATE=DateTime.Parse("2009-2-3"),
ACTIONBEGINTIME=DateTime.Parse("2009-2-3"),
ACTIONENDTIME=DateTime.Parse("2009-5-1"),
FLIGHTSNUMBER=13,
ACTIONFEES=100,
act=""
},
new WModels.TgsActionSubmit()
{
NETBARNAME="心悦诚服",
ACTIONDATE=DateTime.Parse("2009-2-3"),
ACTIONBEGINTIME=DateTime.Parse("2009-2-3"),
ACTIONENDTIME=DateTime.Parse("2009-5-1"),
FLIGHTSNUMBER=13,
ACTIONFEES=100,
act=""
},
new WModels.TgsActionSubmit()
{
NETBARNAME="春心荡漾",
ACTIONDATE=DateTime.Parse("2009-2-3"),
ACTIONBEGINTIME=DateTime.Parse("2009-2-3"),
ACTIONENDTIME=DateTime.Parse("2009-5-1"),
FLIGHTSNUMBER=13,
ACTIONFEES=100,
act=""
}
};
var jsonData = new
{
rows = (
from model in questions
select new
{
cell = new string[]
{
model.NETBARNAME.ToString(),
model.ACTIONDATE.ToString(),
model.ACTIONBEGINTIME.ToString(),
model.ACTIONENDTIME.ToString(),
model.FLIGHTSNUMBER.ToString(),
model.ACTIONFEES.ToString(),
model.act.ToString()
}
}).ToArray()
};
return Json(jsonData);
}
还是从http://www.trirand.com/blog/?page_id=393/help/loadcompletesetrowdata-elem0-undefined论坛上找到的。