Hi
I am passing below 2 columns to dynamic table. I want 1 more column = Actions. In some components i may have Edit..Delete.
In some components i may have 3 like Edit,Delete,View. How this can be done dynamically
this.columns = [
{ title: "Type", name: "name" , visible: true },
{ title: "Description", name: "description" , visible: true },
Thanks
Prasad RaveendranPosted Jun 30, 2024, 7:35 PM
To make the dynamic table more flexible in terms of adding multiple actions, you can define a more generic approach where each row's actions can be specified individually. Here's how you can achieve this:
2. Update the Template to Use Row-Specific Actions: Modify the template to use the actions array from each row.
3. Component Code: Update the component to include the row-specific actions.
With this approach:
dataarray can specify its own set of actions.actionsarray for each row to determine which buttons to display.edit,delete,view) handle the respective actions for the rows.This setup makes it easy to add or remove actions for each row individually, providing a more dynamic and flexible solution.
Jayraj ChhayaPosted Jun 27, 2024, 8:57 AM
To dynamically add an "Actions" column with varying actions to a table in Angular, you can modify the
this.columnsarray by adding a new object for the "Actions" column. You can then conditionally populate this column based on the component requirements.