【问题标题】:Dropdown inside a kendo grid in ReactReact 中剑道网格内的下拉菜单
【发布时间】:2018-01-24 17:17:20
【问题描述】:

我想要完成的是以尽可能好的方式在网格内放置一个下拉菜单。从我在 Angular 中看到的情况来看,他们可以在模板中做到这一点。在 react 中,这是可用的,但不可能使用任何类型的组件。

仅支持“字符串”形式的模板。不支持 React 组件形式的模板。

有什么更好的方法来做到这一点?

【问题讨论】:

    标签: reactjs kendo-ui kendo-grid


    【解决方案1】:

    使用最新版本的 Kendo react Grid,基于此演示 https://www.telerik.com/kendo-react-ui/components/grid/editing/editing/

    以下是如何应用自定义单元格:

    <GridColumn cell={this.CommandCell} />
    ...
    class DropDownCell extends GridCell {
    //...
    handleChange(e) {
        this.props.onChange({
            dataItem: this.props.dataItem,
            field: this.props.field,
            syntheticEvent: e.syntheticEvent,
            value: e.target.value
        });
    }
    //...
    render() {
        const value = this.props.dataItem[this.props.field];
    
        if (this.props.dataItem.inEdit) {
        return (
            <td>
                <DropDownList
                    //...
                />
            </td>
        );
    }
    

    在此处查看完整的可运行版本:https://stackblitz.com/edit/react-grid-dropdown-editor

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-10
      • 1970-01-01
      • 2023-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多