@@ -656,12 +656,13 @@ define([
656656 * @param {object } target
657657 * @param {array } columnInputIdList
658658 * @param {string } tagType input / select (tag type)
659+ * @param {array/boolean } columnWithEmpty boolean array or value to decide whether select tag has empty space
659660 * Usage :
660661 * $(document).on('change', this.wrapSelector('#dataframe_tag_id'), function() {
661- * pdGen.vp_bindColumnSource(that.wrapSelector(), this, ['column_input_id']);
662+ * pdGen.vp_bindColumnSource(that.wrapSelector(), this, ['column_input_id'], 'select', [true, true, true] );
662663 * });
663664 */
664- var vp_bindColumnSource = function ( selector , target , columnInputIdList , tagType = "input" ) {
665+ var vp_bindColumnSource = function ( selector , target , columnInputIdList , tagType = "input" , columnWithEmpty = false ) {
665666 var varName = '' ;
666667 if ( $ ( target ) . length > 0 ) {
667668 varName = $ ( target ) . val ( ) ;
@@ -701,8 +702,22 @@ define([
701702 let { result, type, msg } = resultObj ;
702703 var varResult = JSON . parse ( result ) ;
703704
705+ // check if it needs to add empty option
706+ let addEmpty = false ;
707+ if ( Array . isArray ( columnWithEmpty ) ) {
708+ addEmpty = columnWithEmpty [ idx ] ;
709+ } else {
710+ addEmpty = columnWithEmpty ;
711+ }
712+ if ( addEmpty == true ) {
713+ varResult = [
714+ { value : '' , label : '' } ,
715+ ...varResult
716+ ]
717+ }
718+
704719 // columns using suggestInput
705- columnInputIdList && columnInputIdList . forEach ( columnInputId => {
720+ columnInputIdList && columnInputIdList . forEach ( ( columnInputId , idx ) => {
706721 let defaultValue = $ ( selector + ' #' + columnInputId ) . val ( ) ;
707722 if ( defaultValue == null || defaultValue == undefined ) {
708723 defaultValue = '' ;
@@ -724,6 +739,7 @@ define([
724739 'id' : columnInputId ,
725740 'class' : 'vp-select vp-state'
726741 } ) ;
742+ // make tag
727743 varResult . forEach ( listVar => {
728744 var option = document . createElement ( 'option' ) ;
729745 $ ( option ) . attr ( {
0 commit comments