How to adjust datepicker view inside ag grid cell render template?

后端 未结 2 913
眼角桃花
眼角桃花 2021-01-27 19:26

I use cell rendering in my ag-grid for editing a date field.Inside that cell datePicker is added as shown

view of my cell

But when i am clicking the date icon da

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-27 20:26

    As mentioned before, to be able to use DatePicker in cell you need to create cellEditor instead of cellRenderer, however, cellEditor just like an extension for cellRenderer.

    So for angular, you need to use ICellEditorAngularComp interface and take care of

    agInit(params: any): void // for init value which would be used in DatePicker
    

    and

    getValue(): any // for passing value back to the grid (and update the cell)
    

    don't forget to return true in isPopup(): boolean method - for correct visibility.

    Now, about DatePicker itself, I'm using @danielmoncada/angular-datetime-picker

    (but for sure you can use anything)

    And there are a few things that you need to take care :

    1. what type of value is the datepicker library using
    2. what type of value you will use for view and for database

    and it could be handled with getValue and valueFormatter methods

    That's all for theory, check my demo below and feel free to ask anything related, will try to help.

    DEMO

提交回复
热议问题