EasyUI Forum
April 24, 2024, 07:03:01 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: Menubutton in datagrid toolbar  (Read 4599 times)
y.bykov
Newbie
*
Posts: 49


View Profile
« 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!
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 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);
Logged
y.bykov
Newbie
*
Posts: 49


View Profile
« Reply #2 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.
Logged
y.bykov
Newbie
*
Posts: 49


View Profile
« Reply #3 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.
« Last Edit: February 04, 2018, 12:21:59 AM by y.bykov » 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!