Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 81728

Angular 6 Serverside button click

$
0
0

I have been using datatables for years inside a DurandalJS and KncokoutJS project.
We are now converting to use Angular 6.

If I define a table (below), how can I get the button click event to work? Specifically inside Angular, with a reference to the data of the row? In knockoutJs there was a way to "rebind" the HTML AFTER the server call. I cannot get this to work with Angular.

this.dtOptions = {
ajax: (dataTablesParameters: any, callback: any) => {

                this.myService.myEndPoint(dataTablesParameters).
                    subscribe((resp: any) => {
                        this.myDataCollection = resp.aaData;
                        this.ref.detectChanges();
                        callback({
                                recordsTotal: resp.iTotalRecords,
                                recordsFiltered: resp.iTotalDisplayRecords,
                                data:  resp.aaData
                            });
                    });
            },
            select: true,
            order: [2, "asc"],
            columns: [
                    { data: null,  defaultContent: 'details', orderable: false, class: 'details-control'},
                    { data: null, orderable: false, },
                    { data: "partNumber", orderable: true, },
                    { data: "units", orderable: true },
                    {
                        title: "Display Name",
                        data: null,
                        orderable: true,
                        render: (data, type, full) => `<button (click)="testClick(data.id)">ClickMe</button>`
                    }
                ]
  };

Viewing all articles
Browse latest Browse all 81728

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>