我想在R中的datatable的编辑光泽不是自由文本,并限于某些值

bhmjp9jg  于 12个月前  发布在  其他
关注(0)|答案(1)|浏览(72)

我发现这个答案非常非常有帮助,但如何使其适应两个或更多列
是否有可能限制可用于可编辑数据表中的值?
谢谢你
我尝试扩展输入类型,但它不工作。

a11xaf1n

a11xaf1n1#

使用以下代码段:

callback = JS(
"var tbl = $(table.table().node());",
"var id = tbl.closest('.datatables').attr('id');",
"function onUpdate(updatedCell, updatedRow, oldValue) {",
"  var cellinfo = [{",
"    row: updatedCell.index().row + 1,",
"    col: updatedCell.index().column + 1,",
"    value: updatedCell.data()",
"  }];",
"  Shiny.setInputValue(id + '_cell_edit:DT.cellInfo', cellinfo);",
"}",
"table.MakeCellsEditable({",
"  onUpdate: onUpdate,",
"  columns: [0,1,2],",
"  inputCss: 'my-input-class',",
"  confirmationButton: {",
"    confirmCss: 'my-confirm-class',",
"    cancelCss: 'my-cancel-class'",
"  },",
"  inputTypes: [",
"    {",
"      column: 0,",
"      type: 'list',",
"      options: [",
"        {value: 1,     display: '1'},",
"        {value: 10,    display: '10'},",
"        {value: 100,   display: '100'},",
"      ]",
"    },",
"    {",
"      column: 1,",
"      type: 'list',",
"      options: [",
"        {value: 1,     display: '1'},",
"        {value: 10,    display: '10'},",
"        {value: 100,   display: '100'},",
"      ]",
"    },",
"  ]",
"});"
 )

字符串

相关问题