Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: Custom column label from Other JSON structures

Teerapong free asked 5 years ago


from this example with Other JSON structures

mounted(){
  fetch('https://jsonplaceholder.typicode.com/todos')
    .then(res => res.json())
    .then(json => {
      let keys = ["id", "title", "completed"];
      let entries = this.filterData(json, keys);
      //columns
      this.columns = keys.map(key => {
        return {
          label: key.toUpperCase(),
          field: key,
          sort: 'asc'
        };
      });
      //rows
      entries.map(entry => this.rows.push(entry));
    })
    .catch(err => console.log(err));
}

is it possible to custom label of column like

columns: [
        {
          label: 'Name',
          field: 'name',
          sort: 'asc'
        },
        {
          label: 'Position',
          field: 'position',
          sort: 'asc'
        },

I’m looking forward to your reply.


Magdalena Dembna staff commented 5 years ago

As I understand you would like to rename fields in data from API? I would suggest creating an array of desired columns and map entries from API to match those fields.



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Opened

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB Vue
  • MDB Version: 5.8.0
  • Device: PC
  • Browser: Chrome
  • OS: Windows7
  • Provided sample code: No
  • Provided link: No