Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

248
Visualizações
React.js Mui Treeview: How to make on nodeselect not collapse

I'm trying to make the Treeview not collapse every time I select a node. When node is selected it will render button depending on which node you have selected. Here is an example I made. https://codesandbox.io/s/summer-water-33fe7?file=/src/App.js

about 4 years ago · Santiago Gelvez
2 Respostas
Responde à pergunta

0

TreeItem has a disabled prop which will not allow user to collapse the TreeItem on click. You can dynamically set the value of the disabled prop when you do not want it to collapse.

For example :

const [disabled, setDisabled] = useState(true);

<TreeItem nodeId="5" label="Five" disabled={disabled}>

// setDisabled(false); // Set to false when we want it to be collapsable.
about 4 years ago · Santiago Gelvez Relatório

0

I found a way but not sure if this is the best way so basically I added all the ids that I want to be expanded all the time a.k.a every i.d in the data.

const DataTreeView = ({ treeItems }) => {
    return (
      <TreeView
        defaultCollapseIcon={<ExpandMoreIcon />}
        defaultExpandIcon={<ChevronRightIcon />}
        defaultExpanded={[
          "root",
          "root2",
          "Parent 1",
          "Parent 2",
          "Parent 3",
          "Parent 4",
          "1",
          "2",
          "3",
          "4"
        ]}
        onNodeSelect={action}
      >
        {getTreeItemsFromData(treeItems)}
      </TreeView>
    );
  };
about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda