Code Monkey home page Code Monkey logo

Comments (4)

shinima avatar shinima commented on May 3, 2024

不是很明白你想要做什么 ……

onChangeOpenKeys 这个回调函数只会在用户通过鼠标点击 展开或收拢某一行的时候被调用。

如果想要主动控制 某个节点的展开状态,直接更新 openKeys 即可;如果想要 控制节点是否展示 展开/收拢箭头,可以提供自定义的 options.isLeafNode 方法。

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 这种情况下,因为 节点的展开/收拢状态是受控的,在按钮的点击回调中 更新一下 openKeys 就好了

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

  const renderData = applyTransforms(
    inputDataSourceAndColumns,
    commonTransforms.treeMode({ primaryKey: "id", openKeys, onChangeOpenKeys })
  );

  return (
    <div>
      <button
        onClick={() => {
          onChangeOpenKeys(openKeys.concat(["root"]));
        }}
      >
        展开根节点
      </button>
      <BaseTable {...renderData} />
    </div>
  );
}

from ali-react-table.

LitterPig avatar LitterPig commented on May 3, 2024

是的,我现在可以了。感谢提醒~

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.