@@ -657,12 +657,13 @@ define([
657657 * @param {array } columnInputIdList
658658 * @param {string } tagType input / select (tag type)
659659 * @param {array/boolean } columnWithEmpty boolean array or value to decide whether select tag has empty space
660+ * @param {array/boolean } columnWithIndex boolean array or value to decide whether select tag has index option
660661 * Usage :
661662 * $(document).on('change', this.wrapSelector('#dataframe_tag_id'), function() {
662663 * pdGen.vp_bindColumnSource(that.wrapSelector(), this, ['column_input_id'], 'select', [true, true, true]);
663664 * });
664665 */
665- var vp_bindColumnSource = function ( selector , target , columnInputIdList , tagType = "input" , columnWithEmpty = false ) {
666+ var vp_bindColumnSource = function ( selector , target , columnInputIdList , tagType = "input" , columnWithEmpty = false , columnWithIndex = false ) {
666667 var varName = '' ;
667668 if ( $ ( target ) . length > 0 ) {
668669 varName = $ ( target ) . val ( ) ;
@@ -702,6 +703,20 @@ define([
702703 let { result, type, msg } = resultObj ;
703704 var varResult = JSON . parse ( result ) ;
704705
706+ // check if it needs to add index option
707+ let addIndex = false ;
708+ if ( Array . isArray ( columnWithIndex ) ) {
709+ addIndex = columnWithIndex [ idx ] ;
710+ } else {
711+ addIndex = columnWithIndex ;
712+ }
713+ if ( addIndex == true ) {
714+ varResult = [
715+ { value : varName + '.index' , label : 'index' } ,
716+ ...varResult
717+ ]
718+ }
719+
705720 // check if it needs to add empty option
706721 let addEmpty = false ;
707722 if ( Array . isArray ( columnWithEmpty ) ) {
@@ -711,7 +726,7 @@ define([
711726 }
712727 if ( addEmpty == true ) {
713728 varResult = [
714- { value : '' , label : '' } ,
729+ { value : '' , label : 'Select option... ' } ,
715730 ...varResult
716731 ]
717732 }
0 commit comments