20211209 - IG LOV 기본 값 셋팅하기 - 행 추가 후 기본 값

1. IG 컬럼 >> Advanced

JavaScript Initialization Code :


function( config ) {
    config.defaultGridColumnOptions = {
        defaultValue: function () {
            return {d:"관리자", v: "21"};
        }
    }
    return config;
}

이렇게 하지 않고 보통 다른 컬럼들 하는 것처럼 default 값을 셋팅하게 되면 value 는 셋팅이 되지만 Display 값은 셋팅되지 않아서 위와 같이 json 형식으로 셋팅하면 됨



참고

https://hardlikesoftware.com/weblog/2017/03/31/how-to-hack-apex-interactive-grid-part-4/

https://www.jmjcloud.com/blog/workaround-for-issue-setting-a-default-value-for-the-apex-192-popup-lov

https://community.oracle.com/tech/developers/discussion/4335748/how-to-set-default-value-for-popup-lov

https://docs.oracle.com/en/database/oracle/application-express/21.2/aexjs/model.html#.FieldMeta


    config.initActions = function(actions) {
        var addRow = actions.lookup("selection-add-row");
        var originalAction = addRow.action;
        addRow.action = function(event,el) {
            // do your own stuff before original action if needed
            originalAction(event,el);
            // do your own stuff after original action if needed. This is what page 17 does:
            // after the grid has had a chance to change the selection
            setTimeout(function() {
                apex.item("P17_ENAME").setFocus();
            }, 100);
            return true; // because focus was set
        }
    }


function( config ) {
    config.defaultGridColumnOptions = {
        defaultValue: function( model, record ) {
            return ...;
        }
    }
    return config;
}


var val,
    model = this.data.model,
    rec = this.data.record,
    meta = model.getRecordMetadata(this.data.recordId);

if ( meta.inserted ) {
    val = model.getValue(rec, "JOB")
    if ( val.v === val.d ) {
        model.setValue(rec,"JOB", {d:apex.item("C_JOB").displayValueFor("CLERK"), v: "CLERK"});
    }
    val = model.getValue(rec, "ONLEAVE"); 
    if ( val.v === val.d ) {
        model.setValue(rec,"ONLEAVE", {d:apex.item("C_ONLEAVE").displayValueFor("N"), v:"N"});
    }
}
function(config) {
    config.defaultGridColumnOptions = {
        defaultValue: function( model, srcRecord ) {
            let m,
                name = "";

            if ( srcRecord ) {
                name = model.getValue( srcRecord, "ENAME" ),
                m = /(.*)(\d+)$/.exec( name );

                if ( m ) {
                    name = m[1] + ( parseInt( m[2], 10 ) + 1 );
                } else {
                    name += "_1";
                }
            }
            return name;
        }
    }
    return config;
}

댓글 없음:

댓글 쓰기

20250202 - IG 다운로드 버튼 바로 보이기

JS initialization Code : function (config) {     var $ = apex.jQuery,         toolbarData = $.apex.interactiveGrid.copyDefaultToolbar(),  ...