EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: y.bykov on February 02, 2018, 06:34:46 AM



Title: Menubutton in datagrid toolbar
Post by: y.bykov on February 02, 2018, 06:34:46 AM
Hello!
I need menubutton (multi add actions) in my datagrid toolbar.
I tryed to find decision in source but my effort was fail.
Please explain, how to programmaticaly! create menubutton in datagrid toolbar. I already have few linkbuttons in toolbar.
Thank you!


Title: Re: Menubutton in datagrid toolbar
Post by: stworthy on February 02, 2018, 11:50:38 PM
The code below shows how to create a menubutton programmatically and append to the toolbar.
Code:
var tb = ...  // the toolbar
var menu = $('<div></div>').appendTo('body');
menu.append('<div>Menu Item1</div>');
menu.append('<div>Menu Item2</div>');
menu.menu();
var mb = $('<a href="javascript:;"></a>');
mb.menubutton({
  text: 'MenuButton',
  menu: menu
});
mb.appendTo(tb);


Title: Re: Menubutton in datagrid toolbar
Post by: y.bykov on February 03, 2018, 01:07:23 AM
Thank you!
But it not work for me. I use toolbar like array (in datagrid object config) and in your example menubutton added to already exist toolbar.


Title: Re: Menubutton in datagrid toolbar
Post by: y.bykov on February 04, 2018, 12:15:52 AM
I found decision but it take little source code update.
In datagrid toolbar we can use #id or array of linkbutton configs, but if add linkbutton element (or his childs) it takes little change in build grid method source code.

In the toolbar create part (for->else) add checking
Code:
$.isPlainObject(btn)
for detect it just conf or element, and if it element do
Code:
element.appendTo(td)
In my case it work stable.

If it possible please include this feature in next patch/release.