I am using Angular SlickGrid as parent component and plugin Detail-View as child component. In Detail-View component I'm using few buttons for specific tasks. One of them is button Delete. The issue is when the button is clicked, it triggers components service to delete selected row from the grid by it's ID. Back-end works perfectly. BUT! On the front-end side that row is still visible, unless I reload the page manually. And I need that row from parent component would be deleted on click. I tried to use EventEmitters but aperently SlickGrid doesn't recognizing this functionality. If everything would be in one component, I could ease use: this.angularGrid.gridService.deleteItemById(del_id);
but since detail-view data is passed by rowDetailView
in this.gridOptions
there is no component template tagging like <app-row-detail-view></app-row-detail-view>
My Detail-View Component (child):
@Input() del_id: string;
@Output() onDelete = new EventEmitter<string>();
model: {
id: string;
domains: string;
example_site: string;
status: string;
created: string;
image: string;
};
deleteRecipe() {
if (confirm('Are You sure?')) {
console.log("EVENT 1");
this.del_id = this.model.id;
this.onDelete.emit(this.del_id);
console.log(this.del_id);
return this.recipeService.removeRecipe(this.del_id)
.subscribe(u => {
return u;
});
}
}
My Detail-View HTML(child):
<button (click)="deleteRecipe()">DELETE</button>
My PARENT component HTML:
<angular-slickgrid
gridId="grid11"
[columnDefinitions]="columnDefinitions"
[gridOptions]="gridOptions"
[gridWidth]=1500
[dataset]="dataset"
(onAngularGridCreated)="angularGridReady($event)"
(onDelete)="onDeleted($event)"
>
</angular-slickgrid>
and i can't use here something like [del_id]="del_id"
cuz i get big error in the console..
My Parent component .ts:
onDeleted(del_id: string) {
console.log("EVENT 2");
console.log(del_id);
this.angularGrid.gridService.deleteItemById(del_id);
}
this.gridOptions = {
enableAsyncPostRender: true,
enableFiltering: true,
enableAutoResize: true,
enableCellNavigation: true,
enableGrouping: false,
enableRowDetailView: true,
enableColumnReorder: false,
rowSelectionOptions: {
selectActiveRow: true
},
rowDetailView: {
process: (item: any) => this.simulateServerAsyncCall(item),
viewComponent: RecipeDetailsComponent,
loadOnce: true,
singleRowExpand: true,
useRowClick: true,
panelRows: this.detailViewRowCount
}
};
simulateServerAsyncCall(item: any) {
return new Promise((resolve) => {
const itemDetail = item;
resolve(itemDetail);
});
}
I have tried a lot of articles about EventEmitters, like: https://github.com/6pac/SlickGrid/blob/master/plugins/slick.rowdetailview.js#L10, https://www.infragistics.com/community/blogs/b/infragistics/posts/understanding-output-and-eventemitter-in-angular, https://github.com/ghiscoding/Angular-Slickgrid/blob/master/src/app/modules/angular-slickgrid/models/rowDetailView.interface.ts.
Any help would be very appreciated! Thank You in advance dear colleagues!
deleteItemById
. There's a demo in the Row Detail - Wiki. Just as a reminder, this lib is a wrapper of a jQuery lib, which is why I said you're thinking too much the Angular way. You could also look at the new Cell Menu extension that I've added, it's perfect for Action buttons. – ghiscoding[angularGridParentList]="angularGrid"
and then in the child component I simply use thatangularGrid
reference (with@Input() angularGridParentList: AngularGridInstance;
) to call a row re-render or delete from the parent grid and that's it. – ghiscodingthis.angularGridParentList.deleteItemById(yourId)
and that's it, there's no event or anything, just a reference to the parent grid instance – ghiscoding