简体   繁体   English

内联编辑jqgrid时,datepicker中的minDate

[英]minDate in datepicker while inline editing of jqgrid

I have two jqgrids. 我有两个jqgrids。 On select of any row from 1st grid my 2nd grid is getting loaded. 在从第一网格中选择任何行时,我的第二网格将被加载。 I want to edit the 2nd grid (using inline edit). 我想编辑第二个网格(使用内联编辑)。 There is a column "voucherDate" in 2nd grid and "loanReason" in 1st grid. 在第二个网格中有一个“ voucherDate”列,在第一个网格中有一个“ loanReason”列。 Datepicker is used to edit voucherDate column. Datepicker用于编辑voucherDate列。

Now what I want is to set minDate property in this datepicker and the minDate should be "loanReason" of 1st grid. 现在,我要在此日期选择器中设置minDate属性,并且minDate应该是第一个网格的“ loanReason”。 I am not able to achieve this. 我无法实现这一目标。 Below is some code snippet. 下面是一些代码片段。

ColModel of 2nd grid 第二网格的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 of 1st Grid 第一个网格的ColModel

{name : 'loanReason', index : 'tcl.loan_date',width : 130, align: "center", 
                     searchoptions: { dataInit: initDateSearch, sopt: ['cn'] },
                     editable : true, editoptions : {readonly : 'readonly'}
}

I was trying to do this by using the below code(cboLoanEditList is 1st grid's name) in minDate property of datepicker, but this is not working : 我试图通过在datepicker的minDate属性中使用以下代码(cboLoanEditList是第一个网格的名称)来执行此操作,但这不起作用:

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

I got the answer. 我得到了答案。 Find below code : 查找以下代码:

 {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 }

Instead of writing that jquery line directly inside minDate, I wrote it before the datepicker starts and it just worked like a charm. 我没有在minDate中直接编写该jquery行,而是在datepicker启动之前编写了它,它就像一个符咒一样工作。

What Paulo Diogo suggested was correct but that was from a textbox and not from grid which I wanted. Paulo Diogo提出的建议是正确的,但这是来自文本框而不是我想要的网格。 Anyway thanks Paulo Diogo for replying. 无论如何,感谢Paulo Diogo的回复。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM