file import { StringCol , GenericCol } from './API' ; export class Col { options : any [ ] ; prefix = "" ; suffix = "" ; labelKey = "label" ; valueKey = "value" ; private type = 0 ; constructor ( colOption ) { if ( Array . isArray ( colOption ) ) { this . options = colOption ; this . type = 1 ; } else { this . options = colOption . options || [ ] ; if ( this . options . length > 0 ) { if ( typeof this . options [ 0 ] === 'string' ) { this . type = 1 ; } else { this . type = 2 ; } } else { this . type = 0 ; } this . prefix = colOption . prefix || "" ; this . suffix = colOption . suffix || "" ; this . labelKey = colOption [ 'labelKey' ] || this . labelKey ; this . valueKey = colOption [ 'valueKey' ] || this . valueKey ; } } push ( item ) { this . options . push ( item ) ; } set ( index , item ) { if ( this . type == 0 ) { this . type = typeof item === 'string' ? 1 : 2 ; } this . options [ index ] = item ; } setCol ( ) { } getValue ( index ) { if ( this . type == 1 ) { return this . options [ index ] ; } else { return this . options [ index ] [ this . valueKey ] ; } } getLabel ( index ) { if ( this . type == 1 ) { return this . options [ index ] ; } else { return this . options [ index ] [ this . labelKey ] ; } } }