frappe/datatable

Unable to override defaults in terms of headerDropdown

wgwz opened this issue · 1 comments

wgwz commented

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:

options.headerDropdown = options.headerDropdown || [];
this.options.headerDropdown = [
...DEFAULT_OPTIONS.headerDropdown,
...options.headerDropdown
];

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

wgwz commented

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.