带rhandontable的数字和条件格式
Numeric and Conditional Formatting with rhandsontable
我发现我可以用数字格式格式化rhandinstantable,也可以有条件地格式化rhandontable的样式,但不能两者兼而有之。使用以下代码,似乎只使用了代码的javascript部分。如果能提供任何帮助来合并这两种格式类型,我将不胜感激。
DF = data.frame(int = 1:10, float = rnorm(10), cur = rnorm(10) * 1E5,
lrg = rnorm(10) * 1E8, pct = rnorm(10))
rhandsontable(DF, width = 550, height = 300) %>%
hot_cols(renderer = "
function (instance, td, row, col, prop, value, cellProperties) {
Handsontable.renderers.TextRenderer.apply(this, arguments);
if (row == 2){
td.style.background = 'lightyellow';
}}") %>%
hot_col("float", format = "0.0") %>%
hot_col("cur", format = "$0,0.00") %>%
hot_col("lrg", format = "0a") %>%
hot_col("pct", format = "0%")
您需要引用NumericRenderer而不是TextRenderer
DF = data.frame(int = 1:10, float = rnorm(10), cur = rnorm(10) * 1E5,
lrg = rnorm(10) * 1E8, pct = rnorm(10))
rhandsontable(DF, width = 550, height = 300) %>%
hot_cols(renderer = "
function (instance, td, row, col, prop, value, cellProperties) {
Handsontable.renderers.NumericRenderer.apply(this, arguments);
if (row == 2){
td.style.background = 'lightyellow';
}}") %>%
hot_col("float", format = "0.0") %>%
hot_col("cur", format = "$0,0.00") %>%
hot_col("lrg", format = "0a") %>%
hot_col("pct", format = "0%")
此处讨论问题https://github.com/jrowen/rhandsontable/issues/45
相关文章:
- Google Sheets自定义函数条件格式
- D3.js轴刻度条件格式
- Google Apps 脚本,用于根据一个单元格的值对另一个单元格进行条件颜色格式设置
- 带rhandontable的数字和条件格式
- 如何在不强制的情况下添加条件文本?[101,pdf格式]
- 在ng repeat中按条件设置格式/样式
- 当数据超过 5k 时,为动手提供条件格式的最佳方法
- HTML 表的条件格式因列而异
- 获取条件json格式的表单数据
- moment.js中有条件格式吗
- json格式的jison启动条件
- Jquery UI对话框条件格式
- 条件格式数据表DT R
- Jqgrid条件格式
- 使用google脚本操作数据条件格式和数据验证
- HandsonTable条件格式
- Javascript中的HTML表条件格式代码没有按计划工作
- JavaScript: document.createtextnode中的条件格式
- 关于Handsontable条件格式
- SuiteCRM listview条件格式