DataTables apply column formatting to filter also

前端 未结 2 932
鱼传尺愫
鱼传尺愫 2020-12-29 14:55

When creating a datatable with filter = \'top\' and also using a formatting function on a column, the formatting isn\'t applied to the filter contr

相关标签:
2条回答
  • 2020-12-29 15:32

    Not sure if there's a way to do it. A workaround can be multiplying by 100:

    my_data$wt_pctile <- my_data$wt_pctile * 100
    

    And than displaying as a string with the % sign:

    datatable(my_data, filter = 'top') %>%
      formatString(suffix = "%",columns = "wt_pctile")
    
    0 讨论(0)
  • 2020-12-29 15:35

    I think Yanir is halfway there! What if you multiplied by 100 and then

    datatable(my_data, filter = 'top') %>%
      formatCurrency(columns = "wt_pctile", 
      currency = "%", 
      before = FALSE)
    

    This prevents double or triple %s when sorting.

    0 讨论(0)
提交回复
热议问题