@@ -656,12 +656,13 @@ define([
656
656
* @param {object } target
657
657
* @param {array } columnInputIdList
658
658
* @param {string } tagType input / select (tag type)
659
+ * @param {array/boolean } columnWithEmpty boolean array or value to decide whether select tag has empty space
659
660
* Usage :
660
661
* $(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] );
662
663
* });
663
664
*/
664
- var vp_bindColumnSource = function ( selector , target , columnInputIdList , tagType = "input" ) {
665
+ var vp_bindColumnSource = function ( selector , target , columnInputIdList , tagType = "input" , columnWithEmpty = false ) {
665
666
var varName = '' ;
666
667
if ( $ ( target ) . length > 0 ) {
667
668
varName = $ ( target ) . val ( ) ;
@@ -701,8 +702,22 @@ define([
701
702
let { result, type, msg } = resultObj ;
702
703
var varResult = JSON . parse ( result ) ;
703
704
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
+
704
719
// columns using suggestInput
705
- columnInputIdList && columnInputIdList . forEach ( columnInputId => {
720
+ columnInputIdList && columnInputIdList . forEach ( ( columnInputId , idx ) => {
706
721
let defaultValue = $ ( selector + ' #' + columnInputId ) . val ( ) ;
707
722
if ( defaultValue == null || defaultValue == undefined ) {
708
723
defaultValue = '' ;
@@ -724,6 +739,7 @@ define([
724
739
'id' : columnInputId ,
725
740
'class' : 'vp-select vp-state'
726
741
} ) ;
742
+ // make tag
727
743
varResult . forEach ( listVar => {
728
744
var option = document . createElement ( 'option' ) ;
729
745
$ ( option ) . attr ( {
0 commit comments