<ejs-grid #subjectPersonalNameGrid id="subjectPersonalNameGrid" gridLines="Both" width="100%" [rowHeight]='70'
[dataSource]="catalogingTitle.nameSubjectHeadings" [editSettings]='editSettings' [toolbar]='toolbar'
[allowPaging]="false" allowTextWrap='true' [allowSorting]="true" [textWrapSettings]='wrapSettings'
(actionComplete)='actionComplete($event)' (actionBegin)='actionBegin($event)' (rowDataBound)='rowDataBound($event)'
(toolbarClick)='duplicateClickHandler($event)' (queryCellInfo)='customiseCell($event)'
[selectionSettings]="selectOptions" (dataBound)='dataBound()' (load)='load($event)'>
<e-columns>
<e-column field='rowNo' headerText='rowNo' width=100 [visible]="false" [isPrimaryKey]='true'></e-column>
<e-column type='checkbox' width='20'></e-column>
<e-column field='isDuplicate' headerText='rowNo' width=100 [visible]="false"></e-column>
<e-column headerText="Type of Personal Name" width="200" textAlign="Center" field="personalID_fk"
editType='dropdownedit' [edit]='personalnamesParams' class="boxed-dropdown"
[validationRules]='personalNameTypesRule'>
<ng-template #template let-subjectpersonalnamedata>
<ejs-dropdownlist #typesofPersonalNameData [dataSource]='personalNames' class="boxed-dropdown"
[fields]='personalFields' [placeholder]='selectPersonal' [allowFiltering]='true'
[(ngModel)]='subjectpersonalnamedata.personalID_fk' field="subjectpersonalnamedata.personalID_fk"
[readonly]='true'>
</ejs-dropdownlist>
</ng-template>
</e-column>
</e-columns>
this.personalNameTypesRule = { combinationRule: [this.subjectPersonalNameCombinationCheckFn, 'Combination already available'], required: [true, 'Personal Name Type is required'] };
and duplicate handler in child component(grid component) looks like this
duplicateClickHandler(e: any) {
if (e.item.id === 'duplicaterows') {
let records = [...this.catalogingTitle.nameSubjectHeadings];
this.grid.getSelectedRowIndexes().forEach(index => {
let element = records[index];
this.rowNo = index + this.getGreatestRowNo(this.catalogingTitle.nameSubjectHeadings, 0) + element.rowNo;
var newelement: CatalogingDetailNameSubjectHeadings = new CatalogingDetailNameSubjectHeadings();
newelement.isbn = element.isbn;
newelement.dateAssociated = element.dateAssociated;
newelement.rowNo = this.rowNo;
newelement.personalID_fk = element.personalID_fk;
newelement.isDuplicate = true;
this.grid.addRecord(newelement);
});
localStorage.setItem('catalogingTitle', JSON.stringify(this.catalogingTitle));
}
}
this is how grid looks after duplicate click
