@@ -657,12 +657,13 @@ define([
657
657
* @param {array } columnInputIdList
658
658
* @param {string } tagType input / select (tag type)
659
659
* @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
660
661
* Usage :
661
662
* $(document).on('change', this.wrapSelector('#dataframe_tag_id'), function() {
662
663
* pdGen.vp_bindColumnSource(that.wrapSelector(), this, ['column_input_id'], 'select', [true, true, true]);
663
664
* });
664
665
*/
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 ) {
666
667
var varName = '' ;
667
668
if ( $ ( target ) . length > 0 ) {
668
669
varName = $ ( target ) . val ( ) ;
@@ -702,6 +703,20 @@ define([
702
703
let { result, type, msg } = resultObj ;
703
704
var varResult = JSON . parse ( result ) ;
704
705
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
+
705
720
// check if it needs to add empty option
706
721
let addEmpty = false ;
707
722
if ( Array . isArray ( columnWithEmpty ) ) {
@@ -711,7 +726,7 @@ define([
711
726
}
712
727
if ( addEmpty == true ) {
713
728
varResult = [
714
- { value : '' , label : '' } ,
729
+ { value : '' , label : 'Select option... ' } ,
715
730
...varResult
716
731
]
717
732
}
0 commit comments