Context menu in footer of datatable, how to get the corresponding column?

I have been evaluating webix to see if we can use it in one of our projects. I’m trying to create a context menu on a footer cell in the datatable widget which allows the user to select an aggregate function to display in the footer. I first attempted this with custom filters, but could not also figure out how to let them select which aggregate they wanted displayed so I decided to try the context menu instead. I have this somewhat working, but have many questions:

https://snippet.webix.com/cg8lje1r

  1. Is this an ok approach or do you recommend something better? My requirements are:
    a. Column reorder, column filter, column resize, and header menu are all enabled.
    b. The user can select for any numeric column the aggregate from the following list (None, Min, Max, Count, Sum, Average). I have shown None, Min and Average in my sample.
    c. When the user selects an item, the aggregate is shown in the footer (this would preferable work with state saving and stay present through reordings/filtering/resizing events).
  2. Lines 28-40 or Lines 44-54 I am hard coding the column id. I could not figure out a simple way of getting this value. When using filters this is passed in to the method, but in context menu I am struggling to figure this out.
  3. Lines 88-109, whenever any of the events listed there get triggered, the attachment of the context menu to the footer is lost. I’m assuming this is because the footer is being redrawn but perhaps it’s a bug?
  4. In onColumnResize event, you will notice I have a setTimeout call before re-attaching the context menu. I could not figure out why but if you do not wait the 100ms+, the context menu is not re-attached to the footer.