Add custom action button - ng2-smart-table

后端 未结 2 1325
野性不改
野性不改 2021-02-15 04:30

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 = {
         


        
相关标签:
2条回答
  • 2021-02-15 05:02

    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;
    }
    
    0 讨论(0)
  • 2021-02-15 05:19

    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

    https://github.com/akveo/ngx-admin/blob/master/src/app/pages/tables/smart-table/smart-table.component.ts

    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
        }
      };
    
    
    0 讨论(0)
提交回复
热议问题