Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
65
igxCell isAddRow
posted

I am currently adding using the beginAddRowByIndex function, and one thing I noticed is that when I add a row with the following columns, a placeholder value (header text) is shown in the entityId and description columns, but not the dataType column. 

<igx-column field="entityId" header="Property Id" [sortable]="true"></igx-column>
<igx-column field="description" header="Description" [sortable]="true"></igx-column>
<igx-column field="dataType" header="Data type" [sortable]="true">
	<ng-template igxCell let-val let-cell="cell">{{val | lookup: dataTypesLookup}}</ng-template>
</igx-column>

After digging through the cell.component.html file, I noticed that in the #addRowCell template, it's using a property called isEmptyAddRowCell to conditionally render the cell value, or the header. Given an ng-template with the igxCell directive, is there any way to determine the following:

  1. If the cell.row is a new row, aka, isAddRow. I see some stuff in the codebase like let-row, but that yields undefined for me.
  2. Is there a way to get access to the parent IgxGridCellComponent component, so that the its properties like isEmptyAddRowCell and template can be used?
Parents
  • 1320
    Offline posted

    Hello Michael,

    After investigating this further, I determined that addRowCell template is not applied to the Data Type column because another template is added to this column.

    Additionally, what I could suggest is checking if the value of the cell component is undefined and if there is a template applied to the cell and setting the cell value to the column field.

    public beginAddRow() {

        this.grid1.beginAddRowByIndex(2);

        this.grid1.getRowByIndex(2).cells.forEach((cell) => {

          if (cell.column.bodyTemplate && !cell.value) {

            cell.value = cell.column.field;

          }

        });

      }

    Furthermore, in a method bound to the rowEditExit event the value of the cell would be set back to undefined if the value equals the filed name.

    public rowEditExit(evt) {

        if (evt.isAddRow && evt.newValue?.OrderDate === 'OrderDate') {

          evt.newValue.OrderDate = undefined;

        }

      }

    I have prepared a sample, demonstrating the described behavior. Please test it on your side and let me know if you need any further information regarding this matter.

    Regards,
    Monika Kirkova,
    Infragistics

Reply Children