revolist / revogrid

Powerful virtual data grid smartsheet with advanced customization. Best features from excel plus incredible performance 🔋
https://rv-grid.com
MIT License
2.7k stars 169 forks source link

InitialHeaderClick Event Handling with Row Headers and sorting=true #200

Open stevexm opened 3 years ago

stevexm commented 3 years ago

Hi, I am using revogrid with row headers turned on, as well as utilizing sortable columns. I think there is a minor bug whenever a click is made in the "initial column header", the one that sits above the row headers. Here is the exception:

revo-grid_10.entry.js:1 Uncaught (in promise) TypeError: Cannot read property 'sortable' of undefined at HTMLElement.<anonymous> (revo-grid_10.entry.js:1) at K (index-a7f99799.js:1) at Object.emit (index-a7f99799.js:1) at Object.onClick (revo-grid_10.entry.js:1) at HTMLDivElement.onClick (revo-grid_10.entry.js:1)

The issue is in the headerclick listener in sorting.plugin.ts (~ line 58), where the event detail is looked at:

if (!e.detail.column.sortable) { return; }

In the case of having row headers on, e.detail.column is undefined and an exception is thrown. The fix is straightforward:

if (!e.detail.column || !e.detail.column.sortable) { return; }

Hope this helps,

Steve

revolist commented 3 years ago

Hello @stevexm, thank you for this update, we shall check it shortly. I would recommend for the future to make a pull request with a fix, it'll be easier to review and update. Appreciate your feedback.