Reputation: 522
I'm trying to add a button to custom action, but a new column is not added in the action, making the button overlap with the others.
Code:
settings = {
actions: {
custom: [
{
name: 'Button',
title: 'Button ',
}
],
},
columns: {
name: {
title: 'Full name'
},
email: {
title: 'Email'
},
lastLogin: {
title: 'Last Login'
}
}
};
I needed to put a link to the image, because I have little reputation here and the image tool is blocked for me.
What am I doing wrong?
Upvotes: 11
Views: 26245
Reputation: 1820
Appending @payal s answer.
Adding hover effect.
CSS
::ng-deep {
.my-custom-action:hover {
color: red;
}
ng2-st-tbody-edit-delete {
display: none;
height: 0 !important;
}
ng2-st-tbody-custom {
display: flex;
text-align: center;
}
}
Component
actions: {
custom: [
{
name: 'view',
title: '<i class="my-custom-action ion-eye" title="View"></i>',
},
{
name: 'delete',
title: '<i class="my-custom-action ion-trash-b" title="Delete"></i>',
},
],
add: false,
edit: false,
delete: false,
position: 'right',
},
Upvotes: 0
Reputation: 5264
.ts
actions: {
// delete: false,
add: false,
custom: [
{
name: 'doclist',
title: '<i class="nb-arrow-thin-right" title="doclist"></i>',
},
],
position: 'right'
},
.scss
:host ::ng-deep tr .ng2-smart-actions{ display: flex; }
:host ::ng-deep nbng2-st-tbody-custom {display: flex;}
:host ::ng-deep ng2-st-tbody-edit-delete a.ng2-smart-action {display: inline-block !important;}
:host ::ng-deep ng2-st-tbody-create-cancel a.ng2-smart-action {display: inline-block !important;}
:host ::ng-deep ng2-st-tbody-custom a.ng2-smart-action.ng2-smart-action-custom-custom {
display: inline-block;
width: 80px;
text-align: center;
}
Upvotes: 0
Reputation: 61
There is one another css to align items,
::ng-deep {
ng2-st-tbody-edit-delete {
display: none;
height: 0 !important;
}
ng2-st-tbody-custom {
display: flex;
text-align: center;
}
}`
Upvotes: 2
Reputation: 464
angular has deprecated the /deep/
combinator so I did the following for the same issue:
Added a style class in global css:
.ng2-custom-actions-inline {
.ng2-smart-action-custom-custom {
display: inline-block !important;
height: auto !important;
width: auto !important;
}
}
Set the settings.rowClassFunction
property in the smarttable's settings array:
rowClassFunction: (row) => { return 'ng2-custom-actions-inline' }
I got a clue from this answer:
https://github.com/akveo/ng2-smart-table/issues/779#issuecomment-428494547
Upvotes: 0
Reputation: 443
Now you can use just like below to change action icons of ng2 smart table. You can change the side of the action column use position: "right"
property. for more refer
settings = {
edit: {
editButtonContent: '<i class="nb-edit"></i>',
saveButtonContent: '<i class="nb-checkmark"></i>',
cancelButtonContent: '<i class="nb-close"></i>',
confirmSave: true
},
delete: {
deleteButtonContent: '<i class="nb-trash"></i>',
confirmDelete: true
},
columns: {
id: {
title: "Id",
filter: true
},
name: {
title: "Name",
filter: true
},
transport: {
title: "Transport",
filter: true,
valuePrepareFunction: value => {
return value === 1 ? "Yes" : "No";
}
},
route: {
title: "Route",
filter: true
},
telephone: {
title: "Telephone",
filter: true
},
mobile: {
title: "Mobile",
filter: true
},
land_name: {
title: "Land Name",
filter: false
}
},
actions: {
add: false,
position: "right"
},
pager: {
display: true,
perPage: 10
}
};
Upvotes: 0
Reputation: 525
you can try this. change your setting to:
settings = {
hideSubHeader: true,
actions: {
custom: [
{
name: 'yourAction',
title: '<i class="ion-document" title="YourAction"></i>'
},
{
name: 'editAction',
title: '<i class="ion-edit" title="Edit"></i>'
},
{
name: 'deleteAction',
title: '<i class="far fa-trash-alt" title="delete"></i>'
}
],
add: false,
edit: false,
delete: false
}
...
};
then add this into your component.scss
:host /deep/ ng2-st-tbody-edit-delete {display: flex !important;
height: 0 !important;
}
:host /deep/ ng2-st-tbody-custom a.ng2-smart-action.ng2-smart-action-custom-custom {
display: inline-block;
width: 50px;
text-align: center;
font-size: 1.1em;
}
:host /deep/ ng2-st-tbody-custom a.ng2-smart-action.ng2-smart-action-custom-custom:hover {
color: #5dcfe3;
}
Upvotes: 34