jrowen / rhandsontable

A htmlwidgets implementation of Handsontable.js
http://jrowen.github.io/rhandsontable/
Other
383 stars 148 forks source link

Show different colHeaders than are used internally/in the code #428

Open LogFlames opened 1 year ago

LogFlames commented 1 year ago

Hi,

I wonder if this is possible to do/feature request:

I would like to show the user(/on the webpage) different names for the columns than the code uses. For example, if I have a data frame with

DF <- data.frame(weight = 1:10, age = 2:11)
rhandsontable(DF)

The user is shown those names (weight and age). I would like to have something like the following:

DF <- data.frame(weight = 1:10, age = 2:11)
rhandsontable(DF, colHeaders = c("Weight (g)", "Age (years)"))

But in this case, these names are returned by hot_to_r(input$hot) aswell and cannot be used by the rest of the code.

LogFlames commented 1 year ago

I solved it using a htmlwidget callback

  hot <- htmlwidgets::onRender(hot, "
    function(el, x, data) {
      var hot = this.hot;
      hot.updateSettings({'colHeaders': data});
    }
  ", data = colheaders)