ejs-menu get selected value on click

Hi,
Can you please provide a example how can a get the selected value on click event on ejs.menu.
This what I have tried. I don't see any method to get selected item on this.$refs.menuObj.

<template>
<div>
    <ejs-menu ref="menuObj" :items='menuItems' @select="onSelect()"></ejs-menu>
</div>
</template>
   data: function() {
        return {
           menuItems:  [
                { text: 'Add new user' },
                { text: 'Help' }
            ]
        };
    },
    methods: {
        onSelect: function () {
            console.log("clikkkkkkk"this.$refs.menuObj.ej2Instances);
        },
    }

1 Reply 1 reply marked as answer

GK Gayathri KarunaiAnandam Syncfusion Team May 13, 2021 01:30 AM UTC

Hi Bogdan, 

Thanks for using Syncfusion Products. 

We have checked your reported query, you can use the item property from the argument in the select event to get the selected value. Please check the below code snippet. 

Codesnippet: 
<template> 
  <div> 
    <ejs-menu :items="menuItems" :select="select"></ejs-menu> 
  </div> 
</template> 

<script> 
export default { 
  data: function () { 
    return { 
      menuItems: [ 
        { 
          text: "Events", 
          items: [ 
            { text: "Conferences" }, 
            { text: "Music" }, 
            { text: "Workshops" }, 
          ], 
        }, 
        { 
          text: "Movies", 
          items: [{ text: "Now Showing" }, { text: "Coming Soon" }], 
        }, 
        { 
          text: "Directory", 
          items: [{ text: "Media Gallery" }, { text: "Newsletters" }], 
        }, 
        { 
          text: "Queries", 
          items: [{ text: "Our Policy" }, { text: "Site Map" }], 
        }, 
        { text: "Services" }, 
      ], 
    }; 
 }, 
  methods: { 
    select: function (args) { 
      console.log(args.item.text); 
    }, 
  }, 
}; 
</script> 
 
For your reference, we have prepared a sample based on this. Please check the below link. 


Please get back to us, if you need further assistance. 

Regards, 
Gayathri K 


Marked as answer
Loader.
Up arrow icon