Angular 9 / TypeScript - Add additional column with icon/call to method
Angular 9 / TypeScript - Add additional column with icon/call to method
RandomUser2
Posts: 3Questions: 2Answers: 0
In the last column of my table I want to display an icon where when clicked launches a popup window.
My table gets it's data from a DB using the ajax call then maps it to an object (here myValues) which then gets bound to the table. Is there a way to intercept this to add what I need?
myValues: any; // Can it be DataTables.ColumnSettings = {} ?
dtOptions: DataTables.Settings {};
this.myValues = [ {data: 'valueId' }, {data, 'myValue'} ];
this.dtOptions = {
...
ajax: {
url: this.URL,
type: 'GET'
},
columns: this.myValues,
columnDefs: [ orderable: true, targets: [_all] }
...
};
Thanks,
This discussion has been closed.
Answers
You can use
columns.render
orcolumns.defaultContent
. Here are a couple examples (not Angular though). You can add the code to display the popup.Uses
columns.defaultContent
:http://live.datatables.net/xijecupo/1/edit
Uses
columns.render
:http://live.datatables.net/qemodapi/1/edit
Kevin
Unfortunately these answers are in JS. I need to know how to do this TS.