嗨,我在 MVC 中使用 Jqgrid,要求就是这样.. 在 jqgrid 的模型弹出窗口中添加/编辑一行.. 我有 4 列..
DateFrom,DateTo,Type,Remarks
并且我使用 jquery datepicker ..
我的要求
添加第一行后.. 在添加第二行时.. DateFrom字段(第二行)应该是先前添加行的DateTo字段的下一个日期。
这是我的网格
initDateEdit = function (elem) {
setTimeout(function () {
$(elem).datepicker({
dateFormat: "m-d-yy",
showOn: "button",
changeYear: true,
changeMonth: true,
showButtonPanel: true,
showWeek: true
});
}, 50);
},
initDateSearch = function (elem) {
setTimeout(function () {
$(elem).datepicker({
dateFormat: "m-d-yy ",
changeYear: true,
changeMonth: true,
showButtonPanel: true,
showWeek: true
});
}, 50);
},
jQuery("#dateGrid").jqGrid({
height: 100,
width: 1000,
colNames: ['DateFrom', 'DateTo', 'Type', 'Remarks'],
colModel: [
{
name: 'DateFrom', index: 'DateFrom', width: 60, editable: true, sorttype: "date",
formatter: 'date',
formatoptions: {
srcformat: 'm/d/Y',
},
editoptions: { dataInit: initDateEdit, size: 14 },
},
{
name: 'DateTo', index: 'DateTo', width: 80, editable: true, sorttype: "date",
formatter: 'date',
formatoptions: {
srcformat: 'm/d/Y',
},
editoptions: {
dataInit: initDateEdit, size: 14,
},
},
{
name: 'Type', width: 80, editable: true, formatter: "select",
edittype: "select", editoptions: { value: "Open:Open;Maintainance:Maintainance;Closed:Closed", defaultValue: "Open" },
},
{
name: 'Remarks', index: 'Remarks', width: 80, editable: true
}
,
],
// multiselect:true,
pager: "#datePager",
loadonce: true,
sortname: 'Client',
ignoreCase: true,
sortorder: 'asc',
gridview: true,
autoencode: true,
rowNum: 10,
rowList: [5, 10, 20, 50],
caption: "Add Durations",
viewrecords: true,
editurl: "clientArray",
onSelectRow: function (id) {
var selRows = $(this).jqGrid('getGridParam', 'selarrrow');
if (selRows.length > 1) {
btnEdit.disabled = true;
btnDel.disabled = true;
}
else if (selRows.length == 1) {
btnEdit.disabled = false;
btnDel.disabled = false;
}
},
}).jqGrid("navGrid", "#datePager", { search: true, edit: false, add: false, del: false, searchtext: "Search" }, {}, {}, {
multipleSearch: true,
overlay: false,
onClose: function () {
$("div#ui-datepicker-div.ui-datepicker").hide();
}
}).jqGrid("filterToolbar", { defaultSearch: "cn" });
});
所以现在我需要访问网格中第一行的DateTo值。并且在 DateFrom 的默认值中编写一个函数来将 1 添加到从DateTo获得的日期并在DateFrom中显示它 有人可以给我任何演示/帮助吗究竟如何让这个功能发挥作用?谢谢!