jQuery UI Widgets › Forums › Navigation › Menu, Context Menu › Ajax and ListMenu
Tagged: ajax, data, jqxListBox, jqxListMenu, list menu, ListBox, load, load on demand, Menu, source
This topic contains 4 replies, has 2 voices, and was last updated by tomto 10 years ago.
-
AuthorAjax and ListMenu Posts
-
Hello,
How to load data on demand in ListMenu with ajax ? Like jqxTree.
It is possible, i can’t found how ?
Thank’s
Hello tomto,
Here is an example:
<!DOCTYPE html><html lang="en"><head> <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" /> <script type="text/javascript" src="../../scripts/jquery-1.10.2.min.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxpanel.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxlistbox.js"></script> <script type="text/javascript"> $(document).ready(function () { var listBox = $('#jqxListBox'); var source = null; listBox.jqxListBox({ displayMember: "ContactName", valueMember: "CompanyName", width: 200, height: 250 }); $("#loadData").click(function () { $.ajax({ async: false, url: "source.htm", success: function (data, status, xhr) { source = { datatype: "json", datafields: [ { name: 'CompanyName' }, { name: 'ContactName' } ], id: 'id', localdata: $.parseJSON(data) }; } }); var dataAdapter = new $.jqx.dataAdapter(source); listBox.jqxListBox({ source: dataAdapter }); }); }); </script></head><body class='default'> <button id="loadData"> Load data</button> <div id="jqxListBox"> </div></body></html>
And here is the contents of source.htm:
[ { "CompanyName": "Alfreds Futterkiste", "ContactName": "Maria Anders", "ContactTitle": "Sales Representative", "Address": "Obere Str. 57", "City": "Berlin", "Country": "Germany" }, { "CompanyName": "Ana Trujillo Emparedados y helados", "ContactName": "Ana Trujillo", "ContactTitle": "Owner", "Address": "Avda.de la Constitucin 2222", "City": "Mxico D.F.", "Country": "Mexico" }, { "CompanyName": "Antonio Moreno Taquera", "ContactName": "Antonio Moreno", "ContactTitle": "Owner", "Address": "Mataderos 2312", "City": "Mxico D.F.", "Country": "Mexico" }, { "CompanyName": "Around the Horn", "ContactName": "Thomas Hardy", "ContactTitle": "Sales Representative", "Address": "120 Hanover Sq.", "City": "London", "Country": "UK" }]
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Thank’s
I try this but i need the same for jqxListMenu, not jqxListBox. Apparently source is an invalid property for jqxListMenu, that’s correct ?.Best Regards
ThomasHi Thomas,
I am sorry for the misunderstanding. Unfortunately, content cannot be loaded on demand in jqxListMenu via Ajax. The widget does not have a source property either.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Ok, it’s a pity… maybe in the future…
Thank’s -
AuthorPosts
You must be logged in to reply to this topic.