import { DropDownList } from '@syncfusion/ej2-dropdowns' ; import { isNullOrUndefined } from '@syncfusion/ej2-base' ; import { Column } from '../models/column' ; import { FilterSettings } from '../base/grid' ; import { PredicateModel } from '../base/grid-model' ; import { IGrid } from '../base/interface' ; import { ServiceLocator } from '../services/service-locator' ; import { Query , DataManager } from '@syncfusion/ej2-data' ; import { Dialog , Popup } from '@syncfusion/ej2-popups' ; hidden export class FlMenuOptrUI { private parent : IGrid ; private customFilterOperators : Object ; private serviceLocator : ServiceLocator ; private filterSettings : FilterSettings ; private dropOptr : DropDownList ; private customOptr : { [ key ] : Object ; } [ ] ; private optrData : Object ; private dialogObj : Dialog ; constructor ( parent ? , customFltrOperators ? , serviceLocator ? , filterSettings ? ) { this . parent = parent ; this . serviceLocator = serviceLocator ; this . filterSettings = filterSettings ; this . customFilterOperators = customFltrOperators ; } hidden public renderOperatorUI ( dlgConetntEle , target , column , dlgObj ) { this . dialogObj = dlgObj ; let optr = column . type + 'Operator' ; this . optrData = this . customOptr = ( ! isNullOrUndefined ( this . parent . filterSettings . operators ) && ! isNullOrUndefined ( this . parent . filterSettings . operators [ optr ] ) ) ? this . parent . filterSettings . operators [ optr ] : this . customFilterOperators [ optr ] ; let dropDatasource = this . customOptr ; let selectedValue = this . dropSelectedVal ( column , optr ) ; let optrDiv = this . parent . createElement ( 'div' , { className : 'e-flm_optrdiv' } ) ; dlgConetntEle . appendChild ( optrDiv ) ; let optrInput = this . parent . createElement ( 'input' , { id : column . uid + '-floptr' } ) ; optrDiv . appendChild ( optrInput ) ; this . dropOptr = new DropDownList ( { dataSource : dropDatasource , fields : { text : 'text' , value : 'value' } , open : this . dropDownOpen . bind ( this ) , text : selectedValue } ) ; this . dropOptr . appendTo ( '#' + column . uid + '-floptr' ) ; } private dropDownOpen ( args ) { args . popup . element . style . zIndex = ( this . dialogObj . zIndex + 1 ) . toString ( ) ; } private dropSelectedVal ( col , optr ) { let selValue = '' ; let columns = this . parent . filterSettings . columns ; for ( let column of columns ) { if ( col . field === column . field || ( col . isForeignColumn ( ) && col . foreignKeyValue === column . field ) ) { let selectedField = new DataManager ( this . optrData ) . executeLocal ( new Query ( ) . where ( 'value' , 'equal' , column . operator ) ) ; selValue = ! isNullOrUndefined ( selectedField [ 0 ] ) ? selectedField [ 0 ] . text : '' ; } } if ( selValue === '' ) { selValue = this . optrData [ 0 ] . text ; } return selValue ; } hidden public getFlOperator ( ) { return ( this . dropOptr . value as string ) ; } }