Disable input text but not disable calendar for a edit field inside grid

Is there or can we have a way to disable the input text box but still allow the calendar to work? Currently if the input text is disabled, it disables the whole calendar, but really I just want to prevent users from typing in the date box.

 <ejs-grid #specificationQueueGrid id="reviewSpecificationListGrid" gridLines="Both" [dataSource]="data" [allowFiltering]="true"
        [allowSorting]="true"  [allowMultiSorting]="true" [allowPaging]="true" allowTextWrap="true" (rowDataBound)="rowDataBound($event)" 
        [pageSettings]="pageSettings"  [sortSettings]="sortSettings" (dataBound)="dataBound()" (queryCellInfo)='customiseCell($event)' [editSettings]="editSettings" (actionComplete)='actionComplete($event)'>
        <e-columns>
          <e-column field="orderNumber" headerText="Order #" width="15" textAlign='Center' [allowEditing]='false' isPrimaryKey='true'>
            <ng-template #template let-data>
              <a (click)="onClickOrderNumber(data.orderNumber)" rel='nofollow' href="javascript:void(0);">{{data.orderNumber}}</a>
            </ng-template>
          </e-column>
          <e-column field="followUpDate" headerText="Follow Up Date" width="18" type='date' textAlign='Center' [allowEditing]='true' editType="datepickeredit" [edit]='followUpParam'
            [format]="{type: 'date',  format: 'MM/dd/yyyy'}">
            <!-- <ng-template #template let-data>
              {{data?.followUpDate}}
             </ng-template> -->
            </e-column>
          <e-column field="userName" headerText="User" width="20"  editType='dropdownedit' [edit]='usersParams'>
              <ng-template #template let-data>
                  {{data?.userName}}
                 </ng-template>
          </e-column>
          <e-column field="specificationReviewNotes" headerText="Specification Review Notes" [edit]='reviewNotesParams' width="25" textAlign="Left" headerTextAlign="Center">
              <ng-template #template let-data>
                  {{data?.specificationReviewNotes}}
                 </ng-template>
          </e-column>
        </e-columns>
      </ejs-grid>


this.followUpParam = {
      create: () => {
        this.followUpEle = document.createElement("input");
        return this.followUpEle;
      },
      read: () => {
        return this.followUpObj.value;
      },
      destroy: () => {
        this.followUpObj.destroy();
      },
      write: (args: { rowDataanycolumnColumn } | any=> {
        this.followUpObj = new DatePicker({
          value: args.rowData["followUpDate"],
          blur: (txtargsFocusOutEventArgs | any=> {
            var ddlValue = this.usersDDLobj !== undefined ? ((this.usersDDLobj.value !== null) && (this.usersDDLobj.value !== "0") ? this.usersDDLobj.value.toString() : null) : null;
            this.orderService.updateUserAndReviewNotes(args.rowData.orderNumberddlValuethis.reviewNotesObj.element.value,this.followUpObj.value);
            this.userId = ddlValue;
          }
        });
        this.followUpObj.appendTo(this.followUpEle);
        this.followUpObj.element.addEventListener('keydown', (eKeyboardEventArgs=> {
          if (e.key === 'Enter' && e.which === 13) {
            this.followUpObj.blur.apply(this);
          }
        });
      }
    };





5 Replies 1 reply marked as answer

PG Praveenkumar Gajendiran Syncfusion Team February 19, 2021 11:09 AM UTC

Hi Leela,

Thanks for contacting Syncfusion support.

Based on your query, your requirement is to disable the input element of editor DatePicker component of Grid, for this we have achieved your requirement by using “created” event of DatePicker component as demonstrated in the below code example. 

Please refer the below code example and sample for more information,

Code Example:
 
<div class="control-section"> 
  <div class="col-lg-9"> 
    <ejs-grid #normalgrid id="Normalgrid" [dataSource]="data" allowPaging="true" [pageSettings]="pageSettings" [editSettings]="editSettings"  [toolbar]="toolbar" > 
      <e-columns> 
               <e-column field='OrderID' headerText='Order ID' width='140' textAlign='Right' isPrimaryKey='true' [validationRules]='orderidrules'></e-column> 
                <e-column field='CustomerID' headerText='Customer ID' width='140' [validationRules]='customeridrules'></e-column> 
                <e-column field='Freight' headerText='Freight' width='140' format='C2' textAlign='Right' editType='numericedit' [validationRules]='freightrules'></e-column> 
                <e-column field='OrderDate' headerText='Order Date' width='120' [edit]="dpParams" [format]='formatoptions' textAlign='Right'></e-column> 
                <e-column field='ShipCountry' headerText='Ship Country' width='150' editType='dropdownedit' type="string" ></e-column> 
      </e-columns> 
    </ejs-grid> 
  </div> 
</div> 
[app.component.ts] 
export class AppComponent { 
  public elem: HTMLElement; 
  public datePickerObj: DatePicker;
  public dpParams: IEditCell; 


  public ngOnInit(): void {   

    this.dpParams = {  //cellEditTemplate 
        create: () => {    //create function is used to create the element at time of initialization 
          this.elem = document.createElement("input"); 
          return this.elem; 
        }, 
        read: () => {   //read function is used to read the value from component at time of save. 
         return this.datePickerObj.value; 
        }, 
        destroy: () => {  //destroy function is used to destroy the component. 
         this. datePickerObj.destroy(); 
        }, 
        write: args => {  //write function is used to create custom component or assign default value at time of editing. 
          this.datePickerObj = new DatePicker({         //DatePicker Component 
                    value: new Date(args.rowData[args.column.field]), 
                    floatLabelType: 'Never', 
                    created: created.bind(this), 
                }); 
         function created(){ 
                  this.datePickerObj.inputElement.disabled = true     //disable the input element of DatePicker Component 
          } 
        this.datePickerObj.appendTo(this.elem);  
    }; 
  } 

Sample: https://stackblitz.com/edit/angular-mjyapv-gq3aiz?file=app.component.ts

Documentation Link: https://ej2.syncfusion.com/angular/documentation/grid/edit/#cell-edit-template

Please get back to us if you need further assistance.

Regards,
Praveenkumar G 


Marked as answer

UN Unknown Syncfusion Team February 19, 2021 05:18 PM UTC

Thanks alot Praveen,this worked fine for me

Please help me with one more thing here 
trying to add z-index to datepicker field as calendar is going behind header bar ,which doesnt seem to work.let me know which class I should override
I could see inline styling for this element in Developers tools which cannot be overrridden


.e-datepicker,.e-calendar {
  z-index10001 !important;
}





MN Manikandan Nallathambi Syncfusion Team February 22, 2021 10:14 AM UTC

Hi Leela Mounika,

Thanks for the update. 
Based on your query we suspect that you want to add z-index to the datepicker component while editing the row. By default in EJ2 grid, the datepicker component is displayed like the below screenshot.  
Screenshot: 


For your convenience we have attached the sample for your reference,

Sample: https://stackblitz.com/edit/angular-mjyapv-1xwfqb?file=app.component.ts 
So please share us the below information that will be helpful to provide solution as soon as possible,  
  1. Please explain your exact requirement in video demo or screenshot.
  2. Please explain the purpose of using z-index to the datepicker component.
  3. Share the Syncfusion package version.

Regards,
Manikandan N 



UN Unknown Syncfusion Team February 22, 2021 10:40 AM UTC

I have a banner which is hiding the calendar for first row for smaller devices, I want datepicker to come in the front ,this is the reason why I need z-index to my calendar.

2. "@syncfusion/ej2-angular-popups":"^17.4.51"



PG Praveenkumar Gajendiran Syncfusion Team February 23, 2021 01:31 PM UTC

Hi Leela,

Thanks for your update.

We checked our previous provided sample and we were unable to reproduce the reported problem/scenario at our end as the Grid with editor Date picker is displaying fine at our end.

So please share us the below information that will be helpful to validate further on this,  
1)                 Complete code example. 
2)                 Did you use any custom CSS in your sample? 
3)                 Please let us known the reported Date picker component, is inside the Grid or outside the grid? 
4)                 Share us a simple sample to replicate the problem. It would be helpful to identify your problem case better so that we can check and provide the solution based on that. 

Regards,
Praveenkumar G 


Loader.
Up arrow icon