EasyUI Forum

General Category => Bug Report => Topic started by: vennylv on February 25, 2018, 11:39:20 PM



Title: I want to make a toolbar with switchbutton.
Post by: vennylv on February 25, 2018, 11:39:20 PM

I created a datagrid with subgrid.

Configured to create individual toolbar from each subgrid.

I would like to configure toolbar with switchbutton in a javascript style.

Is it possible? Please tell me the solution.



Title: Re: I want to make a toolbar with switchbutton.
Post by: stworthy on February 26, 2018, 12:52:55 AM
Please refer to this code:
Code:
view: detailview,
detailFormatter: function(rowIndex, rowData){
  return '<div class="ddv"></div>';
},
onExpandRow: function(index,row){
  var ddv = $(this).datagrid('getRowDetail',index).find('.ddv');
  var dg = ddv.find('.datagrid');
  if (!dg.length){
    var tb = $('<div></div>');
    dg = $('<table></table>').appendTo(ddv);
    dg.datagrid({
      height: 200,
      columns: [[
        {field:'started',title:'Started',width:100},
        {field:'ended',title:'Ended',width:100}
      ]],
      toolbar: tb
    });
    $('<a href="javascript:;"></a>').appendTo(tb).linkbutton({
      plain: true,
      iconCls: 'icon-add',
      text: 'Add'
    });
    $('<a href="javascript:;"></a>').appendTo(tb).linkbutton({
      plain: true,
      iconCls: 'icon-remove',
      text: 'Del'
    });
    $('<input>').appendTo(tb).switchbutton();
    $(this).datagrid('fixDetailRowHeight', index);
  }
}