datatable icon indicating copy to clipboard operation
datatable copied to clipboard

Unable to override defaults in terms of headerDropdown

Open wgwz opened this issue 5 years ago • 1 comments

These lines seem to force users to have to use the default fields for the headerDropdown, IMO it's less surprising to always override the headerDropdown with whatever is passed in the Datatable object. It's also unclear if there is an idiomatic way around this issue using this library:

https://github.com/frappe/datatable/blob/31264d1f4da9445c147fdc1060914aa44fa440fa/src/datatable.js#L52-L56

Or perhaps my JS knowledge is insufficient and there is an obvious way to do this. In any case, feedback appreciated.

wgwz avatar Oct 08 '19 14:10 wgwz

Here is the workaround I am using:

    const datatable = new DataTable(datatableElement, {                                                                                                                                                                                       
      columns: header,                                                                                                                                                                                                                        
      data: userData,                                                                                                                                                                                                                         
      checkboxColumn: checkBoxColumn,                                                                                                                                                                                                         
      layout: layout,                                                                                                                                                                                                                         
      serialNoColumn: serialNoColumn,                                                                                                                                                                                                         
    });                                                                                                                                                                                                                                       
    $("div.dt-dropdown__list-item:nth-child(3)").hide();                                                                                                                                                                                      
    $("div.dt-dropdown__list-item:nth-child(4)").hide(); 

End result of that is being able to hide the "Reset Sort" and the "Remove Column" dropdown options.

wgwz avatar Oct 08 '19 14:10 wgwz