We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Get Menu Data by field

Hello,

I am getting data to ejMenu from WebAPI using DataManager and converting it to local data. I want to get all objects custom field data, but do not know how to do it.

In treeView there is method getTreeData(id), but in ejMenu I do not see something like that method...

I am posting data like this:
loadMenu() {
     var MenuObj = $("#myMenu").data("ejMenu");

     var dataManager = new ej.DataManager({ url: urlToWebAPI, crossDomain: true, adaptor: new ej.UrlAdaptor()});
     var query =  new ej.Query();

     queryPromise.done(function(e) {
          var retriveData = (e.xhr && e.xhr.responseJSON && e.xhr.responseJSON.d) ? e.xhr.responseJSON.d : (e.result ? e.result : []);
          $("myMenu").ejMenu({
               fields: { dataSource: retriveData, parentId: "ParentId", id: "Id", text: "Text", customField: "customField" }
          });
     });
}

In same method I am trying to get data like: MenuObj.model.fields.dataSource, but here I am getting null. Here I need to get all object count and their data by fields name, including customField and in other methods I need to get data by id attribute. Maybe there is a simple way to do that?

1 Reply

KR Keerthana Rajendran Syncfusion Team May 19, 2017 12:56 PM UTC

Hi Agne, 
 
Thank you for contacting Syncfusion support. 
 
We don’t have any public method in our ejMenu similar to TreeView control to get data of menu. The way you have used to get the dataSource of menu is fine but make sure whether you are trying to get this data only after the control is rendered i.e. in the success event of DataManager. If still issue persists kindly revert by attaching a sample to reproduce the issue in our end . 
 
Regards, 
Keerthana. 
 


Loader.
Up arrow icon