简体   繁体   中英

minDate in datepicker while inline editing of jqgrid

I have two 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. Datepicker is used to edit voucherDate column.

Now what I want is to set minDate property in this datepicker and the minDate should be "loanReason" of 1st grid. I am not able to achieve this. Below is some code snippet.

ColModel of 2nd grid

{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

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

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.

What Paulo Diogo suggested was correct but that was from a textbox and not from grid which I wanted. Anyway thanks Paulo Diogo for replying. :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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