2

I have a drop down which contains collection of objects. Drop down should bind by default based on condition

<tr v-for="item in binSalesList">\
  <template v-if="item.IsRemovedBin != isRemoved">\
    <td>{{item.LotteryBinId}}</td>\
    <td>
      <select v-model="item.UpcDescription" v-on:change="upcList_Click(item)">\
        <option v-for="upc in upcList">{{ upc.UpcDescription }}</option>\
    </td>\
    <td>{{item.UPCPrice}}</td>\
    <td>
      <input type="textbox" v-model="item.TicketSoldQty" v-on:keyup="item.TicketSoldAmount=(item.TicketSoldQty*item.UPCPrice)" maxlength="4" size="4" onkeypress="app.checkIntegerValue();" />
    </td>\
    <td>
      <input type="textbox" v-model="item.TicketSoldAmount" maxlength="4" size="4" onkeypress="app.checkIntegerValue();" />
    </td>\
  </template>\ </tr>\
3
  • Can you elaborate a bit? Commented Feb 21, 2017 at 9:18
  • what's that slash at the end of each tag? also please insert your vue syntax. Commented Feb 21, 2017 at 9:18
  • \ is added to write HTML in template of a component in Vue JS Commented Feb 21, 2017 at 9:20

3 Answers 3

2

You have to bind the data in the option tag. Please use the code below,

<option v-for="upc in upcList" v-bind:selected="A.column== B.column" :value="upc.column">{{ upc.column }}</option>
Sign up to request clarification or add additional context in comments.

Comments

2

try this

<select v-model="item.UpcDescription" v-on:change="upcList_Click(item)">\
                                 <option v-for="upc in upcList" 
v-bind:selected="upc.UpcDescription == item.UpcDescription" 
:value="upc.UpcDescription">{{ upc.UpcDescription }}</option>

Comments

2

Please try adding v-if for checking the condition

Comments

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.