0

I have a query Object that returns 357 columns (e.g, fullRecord). For a certain portion of my UI, I want to query through a subset of about 125 of those items and display them in a list. I have the column names of those items I want to display in an array (e.g., colsWanted).

I am trying to figure out how to dynamically iterate through the "colsWanted" array and display the appropriate "fullRecord.colsWanted(Item)" in the vuetify interface. I've tried what feels like a million different iterations of this but here is the latest which shows an error:

    <v-flex v-for="(value, index) in colsWanted" :key="value">
      <v-card flat>
        <span v-if="fullRecord[value] in fullRecord">
          <strong>{{ index }}. {{ fullRecord[value] }}</strong>
        </span>
        <span v-else class="error--text">Not Available</span>
      </v-card>
    </v-flex>

I actually get no errors at all from this; but no results are displayed when they should in fact return results.

Thanks in advance for any assistance.

2
  • @Flame Just a comment about the edit. My linter preferences push stacked, nested formatting of the attributes. Not sure if others have settings the same way but thought I'd share. Commented Aug 10, 2019 at 13:35
  • well this is easier to read I reckon. Situation differs with more attributes ofcourse Commented Aug 10, 2019 at 14:34

1 Answer 1

1

Your object key selection is wrong:

<span v-if="fullRecord[value] in fullRecord">

fullRecord[value] will retrieve the value of the value key, which will not be in fullRecord.

What you should be using is:

<span v-if="value in fullRecord">

or

<span v-if="fullRecord.hasOwnProperty(value)">

Also I would rename value to key since thats what it actually is.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks much for the feedback. I actually decided to go a completely separate route but I'll hold onto the details for the future.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.