【问题标题】:Why does my slider editor not work in Vaadin 8 grid?为什么我的滑块编辑器在 Vaadin 8 网格中不起作用?
【发布时间】:2017-10-06 08:11:17
【问题描述】:

我想创建一个 Vaadin 8 网格,我可以在其中使用滑块编辑 Amount (2) 列中的值(类似于 this example)。

我使用以下代码来创建网格。

fun createGrid(): Grid<Concept> {
    val grid = Grid<Concept>()
    val dataProvider = ListDataProvider<Concept>(ctl.getConcepts())
    grid.dataProvider = dataProvider
    grid.addColumn(Concept::getName)
            .setId("ID")
            .setCaption("ID")
    grid.addColumn(Concept::getDescription)
            .setId("desc")
            .setCaption("Description")
    grid.addColumn(Concept::getOutput)
            .setId("amountNumber")
            .setCaption("Amount")

    val conceptAmountditor = Slider()
    conceptAmountditor.setWidth(100.0f, Sizeable.Unit.PERCENTAGE)
    conceptAmountditor.min = 0.0
    conceptAmountditor.max = 100.0

    grid.addColumn(Concept::getOutput, ProgressBarRenderer())
            .setId("amountBar")
            .setCaption("Amount (2)")
            .setEditorComponent(
                    conceptAmountditor,
                    Concept::setOutput
            )
            .setEditable(true)


    grid.setSizeFull()
    return grid
}

但是当我点击各个行时,没有滑块出现。

我的代码有什么问题?双击特定行时,如何使进度条变为滑块?

【问题讨论】:

    标签: java datagrid kotlin vaadin vaadin8


    【解决方案1】:

    这行得通:

        val amount2Col = grid.addColumn(Concept::getOutput, amount2ColRenderer)
                .setId("amountBar")
                .setCaption("Amount (2)")
        val binder = grid.editor.binder
        val amount2ColSlider = Slider()
        val amount2Binding: Binder.Binding<Concept, Double> = binder.bind(
                amount2ColSlider, Concept::getOutput, Concept::setOutput
        )
        amount2Col.setEditorBinding(amount2Binding)
        amount2Col.setEditable(true)
        grid.editor.setEnabled(true)
    

    有关详细信息,请参阅this page 上的“编辑网格内的项目”部分。

    【讨论】:

      猜你喜欢
      • 2017-07-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-21
      • 1970-01-01
      相关资源
      最近更新 更多