EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Wojak on December 06, 2023, 03:26:59 PM



Title: Datagrid toolbar by array
Post by: Wojak on December 06, 2023, 03:26:59 PM
Hi,
Is there a better way to create toolbar with combobox as array then this?
Code:
var toolbar = $('<div style="padding:2px 4px"></div>').appendTo('body');
var db = $('<input>').appendTo(toolbar);
db.datebox();
var cb = $('<input>').appendTo(toolbar);
cb.combobox();

$('#dg').datagrid({
    toolbar:toolbar
})

I have made something like this, but it only works for a non easyui
Code:
{ text: 'Filter: <select id="test"><option value="1">1</option><option value="2">2</option></select>' }

Also in datagrid code i found that every thing in array that is not a "-" it mades as .linkbutton



Title: Re: Datagrid toolbar by array
Post by: jarry on December 12, 2023, 08:33:11 PM
The combobox component can be attached to the toolbar. Please refer to the code below. Make sure to download the latest version.
Code:
var toolbar = [{
text:'Add',
iconCls:'icon-add',
handler:function(){alert('add')}
},{
text:'Cut',
iconCls:'icon-cut',
handler:function(){alert('cut')}
},'-',{
text:'Save',
iconCls:'icon-save',
handler:function(){alert('save')}
},'-',{
type:'combobox',
data:[{value:'1',text:'text1'},{value:'2',text:'text2'}],
editable:false,
onChange:function(value){
alert(value)
}
}];