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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Menu RemoteData Binding

Thread ID:

Created:

Updated:

Platform:

Replies:

146250 Jul 28,2019 07:57 PM UTC Aug 1,2019 04:03 PM UTC JavaScript - EJ 2 3
loading
Tags: Menu
Stephan Schrade
Asked On July 28, 2019 07:57 PM UTC

Hi support,
I'm using the Syncfusion javascript controls with a Yii2 Framework as backend.
I have used your menu template example which uses var data =

{
category: {
value: 'Products',
count: '30+'
},
options: [
{ value: 'JavaScript', url: 'javascript' },
{ value: 'Angular', url: 'angular' },
{ value: 'ASP.NET Core', url: 'core' },
{ value: 'ASP.NET MVC', url: 'mvc' }
]
},

Menu options are set with
var menuOptions = {
items: data,
fields: {
text: ['category', 'value'],
children: ['options']
},
template: '#menuTemplate'
};

This works without problems.
Now I want to load this data with remote binding. But I don't know how to do this.

I have successfully used the data binding with a grid like this:

var data = new ej.data.DataManager({
url: 'http://localhost/rubw/basic/web/athletsrest',
adaptor: new ej.data.WebApiAdaptor()
});

var grid = new ej.grids.Grid({
dataSource: data,
columns: [
{ field: 'name', headerText: 'Name', textAlign: 'Right', width: 120, type: 'string' },
{ field: 'surname', width: 140, headerText: 'Surname', type: 'string' },
{ field: 'gender', headerText: 'gender', textAlign: 'Right', width: 120, format: 'string' },
{ field: 'lightweight', headerText: 'lightweight', width: 140, format: 'string' }
],
allowPaging: true,
pageSettings: {pageSize: 20, pageCount: 8, pageSizes: true},
});

But this does not work with the menu control.

Can you please give me a hint how to achieve this?

TIA Stephan

Vinoth Kumar Sundara Moorthy [Syncfusion]
Replied On July 30, 2019 01:27 PM UTC

Hi Stephan, 
 
Good day to you. 
 
We have checked your requirement “How to bind the remote data in menu component” and we have prepared the sample to bind the remote data in the menu component for your convenience.  
 
 
Could you please check the above sample and get back to us for further assistance on this? 
 
Regards, 
Vinoth Kumar S 


Stephan Schrade
Replied On July 30, 2019 08:38 PM UTC

Many thanks for your answer, but the query is very complex and I don't understand it.
I don't need a query, I just want to get all the data form the backend.
And the I don't understand the syntax of the right hand side of the "items" property.

Your backend generates a response with XML, I'm using JSON.
And I don't know how the structure of the response has to be set in order to work with the menu component.
I thought it hast to be the same like the variable data (screenshot in my initial question).

And if I use
var menuOptions = {
items: ((<Object[]>e.result) as { [key: string]: Object }[]),
fields: {
text: ['category', 'value'],
children: ['options']
},
template: '#menuTemplate'
};
I do get an syntax error within Safari and Mozilla because of the bracket (<)

Vinoth Kumar Sundara Moorthy [Syncfusion]
Replied On August 1, 2019 04:03 PM UTC

Hi Stephen, 
 
Good day to you. 
 
Query 1: And the I don't understand the syntax of the right-hand side of the "items" property. 
 
We would like to let you know that right hand side of items property defines key value pair of objects. 
 
Query 2: Your backend generates a response with XML, I'm using JSON. And I don't know how the structure of the response has to be set in order to work with the menu component. 
 
Please check our JSON format data source in the below link, 
 
For your convenience, we have prepared a sample by using the Json data source. Please check the sample in below 
 
Query 3: I do get a syntax error within Safari and Mozilla because of the bracket (<) 
 
We have checked your reported issue in Mozilla, but we are not able to reproduce it. Could you please provide more details to replicate the issue? 
 
Regards, 
Vinoth Kumar S 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon