EasyUI Forum
May 14, 2024, 12:46:07 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Dynamic menu  (Read 6534 times)
eagleeye
Newbie
*
Posts: 19


View Profile Email
« 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 to create dynamic menu, it works fine  but i need the next customizations.

It's the code for create menu:

Code:
<div id="menu">
            <div id="menu_sistema"></div> <!-- ID for menu_container -->
            <?php include('../menu.php'); ?>
        </div>


Code:
 $.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);
        }
    });


Code:
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
Logged
jarry
Administrator
Hero Member
*****
Posts: 2264


View Profile Email
« Reply #1 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.
Code:
var m = $('<div></div>').appendTo('body').menu({
noline: true,
itemHeight: 34
});
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!