Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

Metronic Vue Datatables


I am testing the metronic vue.js theme and using axios to fetch data from a simple API. I can fetch data in my method and output this in the console, but I cannot update the datatable itself.

here is my code:


export default defineComponent({
name: "kt-entity-list",
components: {
KTDatatable,
},
created() {
this.getEntities();
},
data() {
return {
url: "
headerConfig: ref([
{
key: "checkbox",
sortable: false,
},
{
name: "Entity Title",
key: "entity",
sortable: true,
},
{
name: "Status",
key: "status",
sortable: true,
},
{
name: "Created Date",
key: "createdDate",
sortable: true,
},
{
name: "Actions",
key: "actions",
},
]),
tableData: [],
};
},
mounted() {
setCurrentPageBreadcrumbs("Entity List", ["Entities"]);
},
methods: {
getEntities() {
let AjaxUrl = "
axios.get(AjaxUrl).then((response) => {
console.log("Data:" + JSON.stringify(response.data));
this.tableData = response.data; //// why is this data not updating?
});
},
},
});


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (2)


Hi Laurence,

Could you please try a code below?

this.tableData.splice(0, this.tableData.length, ...response.data);

Instead of

this.tableData = response.data;


We are planning an update of our KTDatatable component in the upcoming release.



Can you please give an example of this in Vue?
https://preview.keenthemes.com/html/metronic/docs/general/datatables/subtable


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(