首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >@blueprintjs/table如何使用箭头/tab键导航

@blueprintjs/table如何使用箭头/tab键导航
EN

Stack Overflow用户
提问于 2018-11-28 00:17:21
回答 1查看 548关注 0票数 1

我想使用箭头/tab键来导航@blueprintjs/table。我跟踪了these document,但找不到任何解决方案。有人能提供示例代码/解决方案吗?

我当前的组件如下所示。

代码语言:javascript
复制
import React, { Component } from 'react';
import { EditableCell, Column, Table } from "@blueprintjs/table";

class TestComponent extends Component {

    constructor(props) {
        super(props);
        this.renderCell = this.renderCell.bind(this);
    }
renderCell (rowIndex, columnIndex)  {
    const value = null;
    return (
        <EditableCell alue={value == null ? "" : value}/>
    );
}
    render() {
        const columns = ["Please", "Rename", "Me"].map((_ , index) => {
            return (
                    <Column key={index} cellRenderer={this.renderCell} enableFocus="true"/>
            );
    });
        return (
            <Table numRows={7} enableFocus="true">{columns}</Table>
        );
    }
}
export default TestComponent;
EN

回答 1

Stack Overflow用户

发布于 2018-11-30 16:08:54

我得到了解决方案,所以回答我自己的问题。

我们应该对表组件使用enableFocusedCell="true",以启用使用箭头/Tab键的导航。

请找到下面的示例代码。

首先导入css

import "@blueprintjs/table/lib/css/table.css";

然后创建一个组件,如下所示

代码语言:javascript
复制
import React, { Component } from 'react';
import { Cell, Column, Table } from "@blueprintjs/table";
const cellRenderer = (rowIndex) => {
    return <Cell>{`$${(rowIndex * 10).toFixed(2)}`}</Cell>
};
class LedgerGroup extends Component {

    constructor(props) {
        super(props);
    }


    render() {
        return (
            <Table numRows={10} enableFocusedCell="true">
                <Column name="Dollars 1" cellRenderer={cellRenderer}/>
                <Column name="Dollars 2" cellRenderer={cellRenderer}/>
            </Table>
        );
    }
}
export default LedgerGroup;
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53503864

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档