【问题标题】:minDate in datepicker while inline editing of jqgrid内联编辑 jqgrid 时 datepicker 中的 minDate
【发布时间】:2015-07-03 12:18:57
【问题描述】:

我有两个 jqgrid。从第一个网格中选择任何行时,我的第二个网格正在加载。我想编辑第二个网格(使用内联编辑)。第二个网格中有一个列“voucherDate”,第一个网格中有一个“loanReason”列。 Datepicker 用于编辑凭证日期列。

现在我想要在这个日期选择器中设置 minDate 属性,并且 minDate 应该是第一个网格的“loanReason”。我无法做到这一点。下面是一些代码sn-p。

第二个网格的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'}
}

我试图通过在 datepicker 的 minDate 属性中使用以下代码(cboLoanEditList 是第一个网格的名称)来执行此操作,但这不起作用:

var row = jQuery("#cboLoanEditList").jqGrid('getRowData',editedRow);
var loanDate = row.loanReason;

【问题讨论】:

标签: javascript jquery jqgrid datepicker


【解决方案1】:

我得到了答案。找到下面的代码:

 {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 行,而是在日期选择器启动之前编写了它,它就像一个魅力一样工作。

Paulo Diogo 的建议是正确的,但那是来自文本框而不是来自我想要的网格。无论如何,感谢 Paulo Diogo 的回复。 :)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-10-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多