How to filter some vuex data in response to a select change2019 Community Moderator ElectionComputed properties not updating when using Lodash and Vuejsvuejs 2 how to watch store values from vuexWhy do my components not updating reactively in this vuejs application?Vue filter and the “Do not mutate vuex store state outside mutation handlers”Vuex action changes component dataUpdate data using vuexUpdating state of vuex array when one item has some changesVuejs generate elements from object inside componentsVue component changing its own property in storeBinding preloaded vuex data with dynamic vuetify v-select

Look at your watch and tell me what time is it. vs Look at your watch and tell me what time it is

How is the Swiss post e-voting system supposed to work, and how was it wrong?

My Graph Theory Students

Recruiter wants very extensive technical details about all of my previous work

How difficult is it to simply disable/disengage the MCAS on Boeing 737 Max 8 & 9 Aircraft?

Why did it take so long to abandon sail after steamships were demonstrated?

How to simplify this time periods definition interface?

How to use deus ex machina safely?

PTIJ: Who should I vote for? (21st Knesset Edition)

Existence of subset with given Hausdorff dimension

Could the Saturn V actually have launched astronauts around Venus?

Happy pi day, everyone!

How do I hide Chekhov's Gun?

Min function accepting varying number of arguments in C++17

Sailing the cryptic seas

Python if-else code style for reduced code for rounding floats

Is a party consisting of only a bard, a cleric, and a warlock functional long-term?

Why is the President allowed to veto a cancellation of emergency powers?

Can I use USB data pins as power source

Do I need life insurance if I can cover my own funeral costs?

Do I need to be arrogant to get ahead?

Does Wild Magic Surge trigger off of spells on the Sorcerer spell list, if I learned them from another class?

Are ETF trackers fundamentally better than individual stocks?

Welcoming 2019 Pi day: How to draw the letter π?



How to filter some vuex data in response to a select change



2019 Community Moderator ElectionComputed properties not updating when using Lodash and Vuejsvuejs 2 how to watch store values from vuexWhy do my components not updating reactively in this vuejs application?Vue filter and the “Do not mutate vuex store state outside mutation handlers”Vuex action changes component dataUpdate data using vuexUpdating state of vuex array when one item has some changesVuejs generate elements from object inside componentsVue component changing its own property in storeBinding preloaded vuex data with dynamic vuetify v-select










0















I'm new to VueJS and still trying to understand all of the constructs. I have a Vuex store and that has several arrays in the state. In a view that uses the vuex store through a computed property, I need to filter the data from the store when a select changes. I don't understand how to wire the select to the officeProjections data in the store.



 <select id="busyness"
name="busyness"
class="form-control mt-1"
v-model="workloadLevels"
@@change="onWorkloadFilterChange($event)">
<option v-for="wl in workloadLevels" v-bind:value="wl.id"> wl.description </option>
</select>

<div v-for="op in officeProjections" class="mt-1">
<div class="card">
<div class="card-body">
<h3 class="card-title"> op.consultantName </h3>
<p> op.workloadLevel <button type="button" v-bind:id="op.ConsultantId" class="btn btn-lg btn-info" data-toggle="popover" data-placement="right" v-bind:data-content="op.comment"></button></p>
<p> op.office </p>
</div>
</div>
</div>









share|improve this question


























    0















    I'm new to VueJS and still trying to understand all of the constructs. I have a Vuex store and that has several arrays in the state. In a view that uses the vuex store through a computed property, I need to filter the data from the store when a select changes. I don't understand how to wire the select to the officeProjections data in the store.



     <select id="busyness"
    name="busyness"
    class="form-control mt-1"
    v-model="workloadLevels"
    @@change="onWorkloadFilterChange($event)">
    <option v-for="wl in workloadLevels" v-bind:value="wl.id"> wl.description </option>
    </select>

    <div v-for="op in officeProjections" class="mt-1">
    <div class="card">
    <div class="card-body">
    <h3 class="card-title"> op.consultantName </h3>
    <p> op.workloadLevel <button type="button" v-bind:id="op.ConsultantId" class="btn btn-lg btn-info" data-toggle="popover" data-placement="right" v-bind:data-content="op.comment"></button></p>
    <p> op.office </p>
    </div>
    </div>
    </div>









    share|improve this question
























      0












      0








      0








      I'm new to VueJS and still trying to understand all of the constructs. I have a Vuex store and that has several arrays in the state. In a view that uses the vuex store through a computed property, I need to filter the data from the store when a select changes. I don't understand how to wire the select to the officeProjections data in the store.



       <select id="busyness"
      name="busyness"
      class="form-control mt-1"
      v-model="workloadLevels"
      @@change="onWorkloadFilterChange($event)">
      <option v-for="wl in workloadLevels" v-bind:value="wl.id"> wl.description </option>
      </select>

      <div v-for="op in officeProjections" class="mt-1">
      <div class="card">
      <div class="card-body">
      <h3 class="card-title"> op.consultantName </h3>
      <p> op.workloadLevel <button type="button" v-bind:id="op.ConsultantId" class="btn btn-lg btn-info" data-toggle="popover" data-placement="right" v-bind:data-content="op.comment"></button></p>
      <p> op.office </p>
      </div>
      </div>
      </div>









      share|improve this question














      I'm new to VueJS and still trying to understand all of the constructs. I have a Vuex store and that has several arrays in the state. In a view that uses the vuex store through a computed property, I need to filter the data from the store when a select changes. I don't understand how to wire the select to the officeProjections data in the store.



       <select id="busyness"
      name="busyness"
      class="form-control mt-1"
      v-model="workloadLevels"
      @@change="onWorkloadFilterChange($event)">
      <option v-for="wl in workloadLevels" v-bind:value="wl.id"> wl.description </option>
      </select>

      <div v-for="op in officeProjections" class="mt-1">
      <div class="card">
      <div class="card-body">
      <h3 class="card-title"> op.consultantName </h3>
      <p> op.workloadLevel <button type="button" v-bind:id="op.ConsultantId" class="btn btn-lg btn-info" data-toggle="popover" data-placement="right" v-bind:data-content="op.comment"></button></p>
      <p> op.office </p>
      </div>
      </div>
      </div>






      vue.js vuejs2 vuex






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 6 at 20:06









      tnk479tnk479

      1056




      1056






















          1 Answer
          1






          active

          oldest

          votes


















          1














          The model bound to the select cannot be the same as the element in the store serving the arrays, in this case you have v-model="workloadLevels" and `v-for="wl in workloadLevels".



          You're going to need a separate model for the selected value:



          v-model="selectedWorkloadLevel"


          And create that property selectedWorkloadLevel in your Vuex store.



          I would not make an action, just a mutation, and I would make it generic:



          SET_VALUE: function(state, payload) 
          Object.keys(payload).forEach((key) =>
          if (state.hasOwnProperty.call(key))
          state[key] = payload[key]

          )



          Then add a get and set computed value for your selectedWorkloadLevel:



          get selectedWorkloadLevel() 
          return this.$store.getters['selectedWorkloadLevel']


          set selectedWorkloadLevel(value)
          this.$store.commit('SET_VALUE', selectedWorkloadLevel: value )



          Then remove the @change handler and update your v-model:



          v-model="selectedWorkloadLevel"





          share|improve this answer

























          • So, then I need to make an action and mutation for updating the selectedWorkloadLevel and then in my onWorkloadFilterChange method i would call that store action?

            – tnk479
            Mar 6 at 20:36











          • @tnk479 See update ^, working kind of swiftly so excuse any errors

            – Ohgodwhy
            Mar 6 at 20:58











          • I did something pretty similar which is use a get and set in the computed property. Trying it your way since I am learning.

            – tnk479
            Mar 6 at 21:05










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55031360%2fhow-to-filter-some-vuex-data-in-response-to-a-select-change%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          The model bound to the select cannot be the same as the element in the store serving the arrays, in this case you have v-model="workloadLevels" and `v-for="wl in workloadLevels".



          You're going to need a separate model for the selected value:



          v-model="selectedWorkloadLevel"


          And create that property selectedWorkloadLevel in your Vuex store.



          I would not make an action, just a mutation, and I would make it generic:



          SET_VALUE: function(state, payload) 
          Object.keys(payload).forEach((key) =>
          if (state.hasOwnProperty.call(key))
          state[key] = payload[key]

          )



          Then add a get and set computed value for your selectedWorkloadLevel:



          get selectedWorkloadLevel() 
          return this.$store.getters['selectedWorkloadLevel']


          set selectedWorkloadLevel(value)
          this.$store.commit('SET_VALUE', selectedWorkloadLevel: value )



          Then remove the @change handler and update your v-model:



          v-model="selectedWorkloadLevel"





          share|improve this answer

























          • So, then I need to make an action and mutation for updating the selectedWorkloadLevel and then in my onWorkloadFilterChange method i would call that store action?

            – tnk479
            Mar 6 at 20:36











          • @tnk479 See update ^, working kind of swiftly so excuse any errors

            – Ohgodwhy
            Mar 6 at 20:58











          • I did something pretty similar which is use a get and set in the computed property. Trying it your way since I am learning.

            – tnk479
            Mar 6 at 21:05















          1














          The model bound to the select cannot be the same as the element in the store serving the arrays, in this case you have v-model="workloadLevels" and `v-for="wl in workloadLevels".



          You're going to need a separate model for the selected value:



          v-model="selectedWorkloadLevel"


          And create that property selectedWorkloadLevel in your Vuex store.



          I would not make an action, just a mutation, and I would make it generic:



          SET_VALUE: function(state, payload) 
          Object.keys(payload).forEach((key) =>
          if (state.hasOwnProperty.call(key))
          state[key] = payload[key]

          )



          Then add a get and set computed value for your selectedWorkloadLevel:



          get selectedWorkloadLevel() 
          return this.$store.getters['selectedWorkloadLevel']


          set selectedWorkloadLevel(value)
          this.$store.commit('SET_VALUE', selectedWorkloadLevel: value )



          Then remove the @change handler and update your v-model:



          v-model="selectedWorkloadLevel"





          share|improve this answer

























          • So, then I need to make an action and mutation for updating the selectedWorkloadLevel and then in my onWorkloadFilterChange method i would call that store action?

            – tnk479
            Mar 6 at 20:36











          • @tnk479 See update ^, working kind of swiftly so excuse any errors

            – Ohgodwhy
            Mar 6 at 20:58











          • I did something pretty similar which is use a get and set in the computed property. Trying it your way since I am learning.

            – tnk479
            Mar 6 at 21:05













          1












          1








          1







          The model bound to the select cannot be the same as the element in the store serving the arrays, in this case you have v-model="workloadLevels" and `v-for="wl in workloadLevels".



          You're going to need a separate model for the selected value:



          v-model="selectedWorkloadLevel"


          And create that property selectedWorkloadLevel in your Vuex store.



          I would not make an action, just a mutation, and I would make it generic:



          SET_VALUE: function(state, payload) 
          Object.keys(payload).forEach((key) =>
          if (state.hasOwnProperty.call(key))
          state[key] = payload[key]

          )



          Then add a get and set computed value for your selectedWorkloadLevel:



          get selectedWorkloadLevel() 
          return this.$store.getters['selectedWorkloadLevel']


          set selectedWorkloadLevel(value)
          this.$store.commit('SET_VALUE', selectedWorkloadLevel: value )



          Then remove the @change handler and update your v-model:



          v-model="selectedWorkloadLevel"





          share|improve this answer















          The model bound to the select cannot be the same as the element in the store serving the arrays, in this case you have v-model="workloadLevels" and `v-for="wl in workloadLevels".



          You're going to need a separate model for the selected value:



          v-model="selectedWorkloadLevel"


          And create that property selectedWorkloadLevel in your Vuex store.



          I would not make an action, just a mutation, and I would make it generic:



          SET_VALUE: function(state, payload) 
          Object.keys(payload).forEach((key) =>
          if (state.hasOwnProperty.call(key))
          state[key] = payload[key]

          )



          Then add a get and set computed value for your selectedWorkloadLevel:



          get selectedWorkloadLevel() 
          return this.$store.getters['selectedWorkloadLevel']


          set selectedWorkloadLevel(value)
          this.$store.commit('SET_VALUE', selectedWorkloadLevel: value )



          Then remove the @change handler and update your v-model:



          v-model="selectedWorkloadLevel"






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 6 at 20:58

























          answered Mar 6 at 20:09









          OhgodwhyOhgodwhy

          35k63969




          35k63969












          • So, then I need to make an action and mutation for updating the selectedWorkloadLevel and then in my onWorkloadFilterChange method i would call that store action?

            – tnk479
            Mar 6 at 20:36











          • @tnk479 See update ^, working kind of swiftly so excuse any errors

            – Ohgodwhy
            Mar 6 at 20:58











          • I did something pretty similar which is use a get and set in the computed property. Trying it your way since I am learning.

            – tnk479
            Mar 6 at 21:05

















          • So, then I need to make an action and mutation for updating the selectedWorkloadLevel and then in my onWorkloadFilterChange method i would call that store action?

            – tnk479
            Mar 6 at 20:36











          • @tnk479 See update ^, working kind of swiftly so excuse any errors

            – Ohgodwhy
            Mar 6 at 20:58











          • I did something pretty similar which is use a get and set in the computed property. Trying it your way since I am learning.

            – tnk479
            Mar 6 at 21:05
















          So, then I need to make an action and mutation for updating the selectedWorkloadLevel and then in my onWorkloadFilterChange method i would call that store action?

          – tnk479
          Mar 6 at 20:36





          So, then I need to make an action and mutation for updating the selectedWorkloadLevel and then in my onWorkloadFilterChange method i would call that store action?

          – tnk479
          Mar 6 at 20:36













          @tnk479 See update ^, working kind of swiftly so excuse any errors

          – Ohgodwhy
          Mar 6 at 20:58





          @tnk479 See update ^, working kind of swiftly so excuse any errors

          – Ohgodwhy
          Mar 6 at 20:58













          I did something pretty similar which is use a get and set in the computed property. Trying it your way since I am learning.

          – tnk479
          Mar 6 at 21:05





          I did something pretty similar which is use a get and set in the computed property. Trying it your way since I am learning.

          – tnk479
          Mar 6 at 21:05



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55031360%2fhow-to-filter-some-vuex-data-in-response-to-a-select-change%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          AWS Lex not identifying response if by a variable The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceEnforcing custom enumeration in AWS LEX for slot valuesHow to give response based on user response in Amazon Lex?Intercepting AWS Lambda Response to a AWS Lex QueryLex chat bot error: Reached second execution of fulfillment lambda on the same utteranceamazon lex showing invalid responseLambda response send back to Lex slot?Response card in Amazon lexAmazon Lex - Lambda response return HTML to botHow can I solve 424 (Failed Dependency) (python) obtained from Amazon lex?

          Алба-Юлія

          Захаров Федір Захарович