Friday, 28 February 2025

Auto Adding Rows in Intrective Grid Using Java Script

 (function() {
    var grid = apex.region("myGrid").widget().interactiveGrid("getViews", "grid"),
        model = grid.model;
    
    function getfromNumber() {
        let startNum = parseInt($v('P107_CHQ_FRM'), 10); 
        
        model.forEach(function(record) {
            let currentNum = parseInt(model.getValue(record, "CHQ_NO"), 10);
            if (!isNaN(currentNum) && currentNum > startNum) {
                startNum = currentNum;
            }
        });
        return startNum;
    }
    
    function numberChqValidation(){
        let endNum = parseInt($v('P107_CHQ_TO'), 10);
        var frmNumber = getfromNumber();
        if (frmNumber < endNum){
            let maxSerialNumber = frmNumber;
            const date = new Date();
            const options = { day: '2-digit', month: 'short', year: 'numeric' };
            const formattedDate = date.toLocaleDateString('en-GB', options).replace(',', '');
            model.forEach(function(record, index) {
                if (model.getValue(record, "CHQ_NO") === null || model.getValue(record, "CHQ_NO") === "") {
                    if (index > 0) {
                        maxSerialNumber++;  
                    }
                    model.setValue(record, "CHQ_NO", maxSerialNumber.toString());
                    model.setValue(record, "VDATE", formattedDate);
                }
            });
        }
    }
    let endNum = parseInt($v('P107_CHQ_TO'), 10); 
    var frmNumber = getfromNumber();
    for(let i = frmNumber; i <= endNum; i++){
    apex.region('myGrid').widget().interactiveGrid("getActions"). invoke('row-add-row');
    }
    numberChqValidation();
})();

No comments:

Post a Comment

Check Internet Connectivity on Local System

if (!navigator.onLine) {     showOfflineAlert(); } else {     // Set a strict 3-second network timeout threshold     const controller = new ...