wxs77577 / rest-admin

Restful Admin Dashboard Based on Vue and Boostrap 4
http://rest-admin.genyii.com
MIT License
624 stars 128 forks source link

Proper use of addon tag in DataTable.vue #12

Closed cscsabai closed 5 years ago

cscsabai commented 5 years ago

May I ask some help how can use the addon tag in DataTable? Following example is working for me:

                 "_actions": { 
                       "toolbar": {
                          "create": False,
                          "delete_all": False
                       },
                       "buttons": { 
                          "show": False,
                           "delete": False,
                      },
                      "addon": {
                          "button": {
                              "label": "testlabel",
                              "href": "/ddd/",
                           },
                      }
                   },

How can I get to append the selected line _id's to the url? Is there any way for it?

BlindBard commented 5 years ago

You can use this method: Add attribute in components/DataTable.vue line 90

:data-id="row.item.id"

full line

<b-btn size="sm" v-for="(button, key) in _.get(actions, 'addon')" :key="key" v-bind="button" :data-id="row.item.id">{{button.label}}</b-btn>

Add onclick in config.js

"_actions": {
  "addon": {
    "button": {
      "label": "Approve",
      "onclick": "alert('Approved ' + this.dataset.id)"
    }
  }
}
cscsabai commented 5 years ago

Thank You. It is working! Save my day :)