我有两个 jqgrid。在从第一个网格中选择任何行时,我的第二个网格正在加载。我想编辑第二个网格(使用内联编辑)。第二个网格中有一个“voucherDate”列,第一个网格中有一个“loanReason”列。 Datepicker用于编辑voucherDate列。
现在我想要的是在此日期选择器中设置 minDate 属性,并且 minDate 应该是第一个网格的“loanReason”。我无法实现这一点。下面是一些代码片段。
第二个网格的 ColModel
{name : 'voucherDate', index : 'voucher_date',width : 150, align: "center", editable : true, editoptions:{size:20,
dataInit:function(el){
$(el).datepicker({
dateFormat:'dd-M-yy',
changeMonth: true,
changeYear: true,
numberOfMonths: 1,
maxDate : '${currentDate}'
});
}},
search : true, searchoptions: { dataInit: repaymentDateSearch, sopt: ['eq','cn'] }, sortable : true }
第一个网格的 ColModel
{name : 'loanReason', index : 'tcl.loan_date',width : 130, align: "center",
searchoptions: { dataInit: initDateSearch, sopt: ['cn'] },
editable : true, editoptions : {readonly : 'readonly'}
}
我试图通过在日期选择器的 minDate 属性中使用以下代码(cboLoanEditList 是第一个网格的名称)来执行此操作,但这不起作用:
var row = jQuery("#cboLoanEditList").jqGrid('getRowData',editedRow);
var loanDate = row.loanReason;
最佳答案
我得到了答案。找到下面的代码:
{name : 'voucherDate', index : 'voucher_date',width : 150, align: "center", editable : true, editoptions:{size:20,
dataInit:function(el){
var row = jQuery("#cboLoanEditList").jqGrid('getRowData',editedRow);
$(el).datepicker({
dateFormat:'dd-M-yy',
changeMonth: true,
changeYear: true,
numberOfMonths: 1,
maxDate : '${currentDate}',
minDate : row.loanDate
});
}},
search : true, searchoptions: { dataInit: repaymentDateSearch, sopt: ['eq','cn'] }, sortable : true }
我没有直接在 minDate 中编写 jquery 行,而是在日期选择器启动之前编写它,它就像一个魅力。
保罗·迪奥戈的建议是正确的,但那是来自文本框而不是我想要的网格。无论如何,感谢保罗·迪奥戈的回复。 :)
关于javascript - jqgrid 内联编辑时日期选择器中的 minDate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31206702/