Code Monkey home page Code Monkey logo

Comments (4)

shinima avatar shinima commented on May 3, 2024

@LitterPig 你看下是否可以通过 BaseTableProps#getRowProps 来实现类似的效果? 就是根据最近一次 treeOptions.onChangeOpenKeys 回调中的 action & key,设置一下相应的行的样式就好了。

function Component() {
  const [openKeys, onChangeOpenKeys] = useState([]);
  const [lastOpenKey, setLastOpenKey] = useState("");

  const renderData = applyTransforms(
    inputDataSourceAndColumns,
    commonTransforms.treeMode({
      primaryKey: "id",
      openKeys,
      onChangeOpenKeys(nextKeys, key, action) {
        // 记录最近一次被展开的 key
        if (action === "expand") {
          setLastOpenKey(key);
        } else {
          setLastOpenKey("");
        }
        onChangeOpenKeys(nextKeys);
      },
    })
  );

  return (
    <div>
      <BaseTable
        dataSource={renderData.dataSource}
        columns={renderData.columns}
        getRowProps={(row, rowIndex) => {
          // 根据最近一次被展开的 key 来设置行的背景色
          if (row.key === lastOpenKey) {
            return { style: { background: "#ccc" } };
          }
        }}
      />
    </div>
  );
}

如果还是需要自定义箭头的颜色的话,我这边可以将相关的配置项开出来。

from ali-react-table.

LitterPig avatar LitterPig commented on May 3, 2024

你这个只能设置单元格的颜色吧,我其实想设置收拢和展示箭头的颜色

from ali-react-table.

shinima avatar shinima commented on May 3, 2024

@LitterPig 好的 这个等我周六加一下吧

from ali-react-table.

shinima avatar shinima commented on May 3, 2024

@LitterPig 已经实现好了
因为这个功能并非常见功能,需要在通过 CSS 类名来控制样式,可以参考这个示例

from ali-react-table.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.