Title: How add MenuButton to toolbar from js
Post by: waltex on December 17, 2015, 02:49:54 AM
i can add a MenuButton to toolbar for pivogrid using only javascript statements. toolbar: [{ //text: 'Layout', handler: function () { $('#dg2').pivotgrid('layout'); } }, {iconCls: 'icon-reload', text: 'Elabora', handler: function () { load_dg2(); }}, {iconCls: 'icon-excel1', text: 'Esporta', handler: function () { JSONToCSVConvertor2($('#dg2').pivotgrid('getRoots'), 'pivot', 'label'); }}, {iconCls: 'icon-database_edit', text: 'parametri pivot', handler: function () { $('#dg2').pivotgrid('layout') }}],
Title: Re: How add MenuButton to toolbar from js
Post by: jarry on December 18, 2015, 12:10:39 AM
Please try to call the 'buildToolbar' function to build the toolbar via javascript code. function buildToolbar(conf){ var tb = $('<div></div>').appendTo('body'); $.map(conf, function(options){ var type = options.type || 'linkbutton'; var a = $('<a href="#"></a>').appendTo(tb); a[type]($.extend({}, options, { plain:true, onClick: options.onClick||options.handler })); }); return tb; }
$(function(){ var conf = [{ text:'Add', iconCls:'icon-add', handler:function(){alert('add')} },{ text:'Cut', iconCls:'icon-cut', handler:function(){alert('cut')} },{ text:'Save', iconCls:'icon-save', type:'menubutton', menu: '#mm', handler:function(){alert('save')} }]; $('#dg').datagrid({ toolbar: buildToolbar(conf) }); })
|