【问题标题】:Bokeh datatable in-cell edition - error in bokeh-tables-0.12.15.js?Bokeh datatable in-cell edition - bokeh-tables-0.12.15.js 中的错误?
【发布时间】:2018-04-04 09:51:21
【问题描述】:

我只是想获得一个可以将数据表的值直接编辑到单元格中的工作示例。

我遇到了 JS 错误,但不幸的是我对 JS 一无所知:/

这是用于重现错误的代码:

from bokeh.plotting import show, curdoc
from bokeh.models import ColumnDataSource
from bokeh.models.widgets.tables import DataTable, TableColumn, BooleanFormatter, CheckboxEditor
from bokeh.models.widgets.tables import NumberFormatter, NumberEditor, IntEditor, TextEditor, StringEditor, StringFormatter

# DataTable construction
dico = dict(
    nom=["Abathur", "Tychus", "Nova"],
    alive=[False] * 3,
    age=[x for x in range(0, 3)])
source_dt = ColumnDataSource(data = dico)
columns = [
    TableColumn(field="nom", title="Nom", editor=StringEditor(), formatter=StringFormatter()),
    TableColumn(field="alive", title="Alive", editor=CheckboxEditor(), formatter=BooleanFormatter(icon="check")),
    TableColumn(field="age", title="Age", formatter=NumberFormatter(), editor=IntEditor())
]
dt = DataTable(width=400, height=600, source=source_dt, columns=columns, editable=True, selectable=True)

# show(dt)

curdoc().add_root(dt)

这是我尝试更改字符串/文本值的数据表的屏幕截图:

当我使用 enter-key 验证或单击其他地方时,数据表被冻结,并且我从 Firefox 中的 JS 控制台收到错误:

与 chrome 相同的观察结果,来自 js 控制台的错误:

工作环境是由 Anaconda 提供的 Windows 10、python 3.6 和 bokeh 0.12.15、webbrowser firefox 59 或 chrome 65 还在 debian 8 上测试了新安装的 anaconda 提供的散景

我做错了吗?您是否有一个可以在单元格中编辑数据表值的工作示例?

编辑: 我能够找到引发错误的代码行,它位于文件 https://cdn.bokeh.org/bokeh/release/bokeh-tables-0.12.15.js 的第 13440 行

var validationResults = currentEditor.validate();
if (validationResults.valid) {                    <<---- RAISE THE ERROR

出于我无法理解的原因,currentEditor.validate(); 没有返回任何内容,validationResults 仍然是 undefined

我还从 github 示例 https://github.com/bokeh/bokeh/blob/master/examples/models/file/data_tables.py 中测试了 data_tables.py,我得到了相同的结果

【问题讨论】:

    标签: python datatable bokeh


    【解决方案1】:

    我终于设法找到了问题: 存档https://cdn.bokeh.org/bokeh/release/bokeh-tables-0.12.15.js 必须更改第 118 行

    // OLD not working code
    CellEditorView.prototype.validate = function () {
            this.validateValue(this.getValue());
        };
    
    // NEW working code
    CellEditorView.prototype.validate = function () {
            return this.validateValue(this.getValue());  <<---- added "return"
        };
    

    通过此修改,我现在可以编辑数据表中的单元格内容。

    我开了一个github issue让有能力的人正确解决https://github.com/bokeh/bokeh/issues/7768

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-02
      • 1970-01-01
      • 2015-11-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多