Home > Blockchain >  Vue setFieldValue sorting based on keys on its own
Vue setFieldValue sorting based on keys on its own

Time:08-10

I've this function I use to upload from csv and save the details in an array and save it

getArray(row) {
  let getDetail = []
  if (row['comment'].trim().length > 0) {
    this.setFieldValue(getDetail, 'Comments', row['comment'])
  }
  if (row['start'].trim().length > 0) {
    this.setFieldValue(getDetail, 'Start Date', this.dateFormat(row['start']))
  }
  if (row['end'].trim().length > 0) {
    this.setFieldValue(getDetail, 'End Date', this.dateFormat(row['end']))
  }
  return getDetail
},

The issue is getDetail is automatically sorted based on keys, so on UI on the table I am displaying it using v-for

I've order as -> Comment, End date, Start date
where as the required is -> Comment, Start date, End date

CodePudding user response:

The correct solution is to avoid using the name as key.

  • Related