How to get Id,Text,ParentId,Url..etc on click event of menu item in client side.

Hi,
I have a ejMenu and i need to get the id, text, url..etc when click on a menu item. But it gives only text of it. If i try to get the id of clicked menu item it gives 'undefined' error. Please help me on this matter.


@Html.EJ().Menu("menu").MenuFields(f => f.Datasource((IEnumerable<KalbizCat_OLE.Controllers.HomeController.MenuJson>)ViewBag.datasource)
.Id("id").Text("text").ParentId("parent").Url("URL")).ClientSideEvents(eve => { eve.Click("clientMenuClick"); })


 function clientMenuClick(event)
    {
        alert(event.id);
    }

Thank you and regard
Kalum

3 Replies

IB Ilakkiya Baskar Syncfusion Team April 19, 2018 09:15 AM UTC

Hi Tommy    
Thank you for contacting Syncfusion Support. 
We analyzed your query. We suggest you to use instance of the Menu component to get the properties value. Please refer the code block below, 
<script> 
        function clientMenuClick(event) { 
            var object = $("#menujson").data("ejMenu"); 
            console.log(object._id); // to get id of the menu 
            console.log(object.model.fields.parentId); // to get the parentid 
            console.log(object.model.fields.url); // to get the url 
            console.log(object.model.fields.id); // to get the field id 
             
        } 
    </script> 
Please refer the sample in the below link, 
 
Let us know if there is any concern, we will be happy to assist you. 
Regards, 
Ilakkiya B 



KA kalum April 19, 2018 03:24 PM UTC

Hi,
It works fine. Thanks so much for your kind support.
Regards
Kalum


IB Ilakkiya Baskar Syncfusion Team April 20, 2018 07:36 AM UTC

Hi Tommy, 
 
Most welcome. We are happy that your issue has been resolved. Let us know if you have any other issues, we will be happy to assist you. 
 
Regards 
Ilakkiya B 


Loader.
Up arrow icon