How to get selected row index on @change event of child Select Dropdown in Element UI?

10,087

Here is the solution :

@change="updateDropdowns(index, $event)"

you can use $event to reference current event.

Share:
10,087
Faizan Saiyed
Author by

Faizan Saiyed

An opportunity to work and upgrade oneself, as well as being involved in an organization that believes in gaining a competitive edge and giving back to the community. I'm presently expanding my solid experience in UI / UX design. I focus on using my interpersonal skills to build good user experience and create a strong interest in my employers. I hope to develop skills in motion design and my knowledge of the Web, and become an honest asset to the business. As an individual, I'm self-confident you’ll find me creative, funny and naturally passionate. I’m a forward thinker, which others may find inspiring when working as a team.

Updated on June 14, 2022

Comments

  • Faizan Saiyed
    Faizan Saiyed almost 2 years

    I'm generating a list of multiple input elements in which one is <el-select>. On changing this select menu, I'm getting value bounded with that select. But here, question is, I also want to get index/row number of the parent v-for items. You can understand what I meant from the following code:

    <el-form-item v-for="(domain, index) in Prescription.domains">
        <div class="col-md-2" v-if="medicineIsSelected === true">
            <small>Select Brand:</small>
            <el-select v-model="domain.SelectedBrand" clearable placeholder="Select" @change="updateDropdowns"> <!-- Here I want to pass {{index}} also -->
              <el-option
                v-for="item in selectedMedicineMetaInfo.BrandName"
                :key="item.value.name"
                :label="item.value.name"
                :value="item.value.rxcui">
              </el-option>
            </el-select>
        </div>
    </el-form-item>
    

    As you can see from above code, I want to pass index in updateDropdowns. I tried passing updateDropdowns(index), here I got the index number but lost the selected value of that dropdown. How can I pass both?

  • Faizan Saiyed
    Faizan Saiyed almost 6 years
    I'm not using any parent-child components. How can I do with ElementUI?
  • Faizan Saiyed
    Faizan Saiyed almost 6 years
    Wow! you are a lifesaver! Thanks a lot! Works perfect!
  • channasmcs
    channasmcs almost 6 years
    easily you can create child component for el-select