EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: devnull on January 23, 2016, 12:34:02 AM



Title: Get datagrid parent from toolbar button [Solved]
Post by: devnull on January 23, 2016, 12:34:02 AM
How can I get the parent datagrid object from within the handler without having to use a jquery selector on the datagrid object ?

Code:
    toolbar: [{
      text: 'Add',
      iconCls: 'icon-add',
      disabled: false,
      handler: function(evt){
        $(this).datagrid('appendRow',{label:'',value:''})
      }
    },{
      text: 'Delete',
      iconCls: 'icon-delete',
      disabled: true,
      handler: function(evt){
        
      }
    }]


Title: Re: Get datagrid parent from toolbar button
Post by: stworthy on January 23, 2016, 08:30:16 AM
Please try this code.
Code:
{
      text:'Add',
      iconCls:'icon-add',
      handler:function(){
        var dg = $(this).closest('.datagrid-wrap').find('>.datagrid-view>.datagrid-f');
        dg.datagrid('appendRow',{})
      }
}


Title: Re: Get datagrid parent from toolbar button
Post by: devnull on January 23, 2016, 04:05:40 PM
Ahh OK, so I have to do it by searching the DOM.

Thanks