Title: Dynamic menu
Post by: eagleeye on April 12, 2016, 07:25:05 AM
Hi i was working with this example http://www.jeasyui.com/forum/index.php?topic=3902.msg9291#msg9291 (http://www.jeasyui.com/forum/index.php?topic=3902.msg9291#msg9291) to create dynamic menu, it works fine but i need the next customizations. It's the code for create menu: <div id="menu"> <div id="menu_sistema"></div> <!-- ID for menu_container --> <?php include('../menu.php'); ?> </div>
$.ajax({ type: "POST", datatype: "json", async: false, url: ruta_getroles, cache: false, success: function (jsondata) { //El método JSON.parse() analiza una cadena de texto como JSON,convert a JSON text into a JavaScript object: menu_data = JSON.parse(jsondata); createMenuBar(menu_data, '#menu_sistema'); //LLama a a funcion que construye el menu }, error: function (xhr, ajaxOptions, thrownError) { //si hubo error en la ejecucion var mensaje = 'Ocurrio un error inesperado, por favor contacte al administrador. Disculpe las molestias.'; $.messager.alert('Sistema de SOLPEDS y Pedidos', mensaje, 'error'); alert(xhr.status); alert(thrownError); } });
function createMenuBar(data, container) { $.map(data, function (btn) { var b = $('<a href="javascript:void(0)"></a>').appendTo(container); if (btn.items) { b.menubutton($.extend({}, btn, { menu: createMenu(btn.items) })); } else { b.linkbutton($.extend({}, btn, { plain: true //noline: true })); } }); function createMenu(items) { var m = $('<div></div>').appendTo('body').menu(); _create(items); return m;
function _create(items, p) { $.map(items, function (item) { m.menu('appendItem', $.extend({}, item, { parent: (p ? p.target : null) })); if (item.items) { var p1 = m.menu('findItem', item.text); _create(item.items, p1); } }); } } }
My question is How to hide the iconCls, i don't need it !! and how to customize the size of menu and submenus? Thanks in advance
Title: Re: Dynamic menu
Post by: jarry on April 12, 2016, 06:46:39 PM
When creating the menu, you can set 'noline' to true to hide the menu line, set 'itemHeight' to specify the height of menu items. var m = $('<div></div>').appendTo('body').menu({ noline: true, itemHeight: 34 });
|