import { extend } from '@syncfusion/ej2-base' ; import { Column } from '../models/column' ; import { IEditCell , IGrid , EJ2Intance } from '../base/interface' ; import { DatePicker , DateTimePicker } from '@syncfusion/ej2-calendars' ; import { isEditable , getComplexFieldID , getObject , getCustomDateFormat } from '../base/util' ; hidden export class DatePickerEditCell implements IEditCell { private parent : IGrid ; private obj : DatePicker ; constructor ( parent ? ) { this . parent = parent ; } public create ( args ) { let complexFieldName = getComplexFieldID ( args . column . field ) ; return this . parent . createElement ( 'input' , { className : 'e-field' , attrs : { id : this . parent . element . id + complexFieldName , name : complexFieldName , type : 'text' , 'e-mappinguid' : args . column . uid } } ) ; } public read ( element ) { return ( < EJ2Intance > element ) . ej2_instances [ 0 ] . value ; } public write ( args ) { if ( args . column . editType === 'datepickeredit' ) { this . obj = new DatePicker ( extend ( dateanddatetimerender ( args , this . parent . editSettings . mode , this . parent . enableRtl ) , args . column . edit . params ) ) ; } else if ( args . column . editType === 'datetimepickeredit' ) { this . obj = new DateTimePicker ( extend ( dateanddatetimerender ( args , this . parent . editSettings . mode , this . parent . enableRtl ) , args . column . edit . params ) ) ; } this . obj . appendTo ( args . element as HTMLElement ) ; } public destroy ( ) { if ( this . obj ) { this . obj . destroy ( ) ; } } } function dateanddatetimerender ( args , mode , rtl ) { let isInline = mode !== 'Dialog' ; let format = getCustomDateFormat ( args . column . format , args . column . type ) ; let value = getObject ( args . column . field , args . rowData ) ; value = value ? new Date ( value ) : null ; return { floatLabelType : isInline ? 'Never' : 'Always' , value : value , format : format , placeholder : isInline ? '' : args . column . headerText , enableRtl : rtl , enabled : isEditable ( args . column , args . type , args . element ) , } ; }