frappe / datatable

The Missing Javascript Datatable for the Web
https://frappe.io/datatable
MIT License
1.02k stars 164 forks source link

Unable to override defaults in terms of headerDropdown #89

Closed wgwz closed 1 year ago

wgwz commented 4 years ago

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 commented 4 years ago

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.