Cookie Consent by Free Privacy Policy Generator Update cookies preferences 📌 VTable usage problem: How to set the expanded and collapsed state of the tree structure

🏠 Team IT Security News

TSecurity.de ist eine Online-Plattform, die sich auf die Bereitstellung von Informationen,alle 15 Minuten neuste Nachrichten, Bildungsressourcen und Dienstleistungen rund um das Thema IT-Sicherheit spezialisiert hat.
Ob es sich um aktuelle Nachrichten, Fachartikel, Blogbeiträge, Webinare, Tutorials, oder Tipps & Tricks handelt, TSecurity.de bietet seinen Nutzern einen umfassenden Überblick über die wichtigsten Aspekte der IT-Sicherheit in einer sich ständig verändernden digitalen Welt.

16.12.2023 - TIP: Wer den Cookie Consent Banner akzeptiert, kann z.B. von Englisch nach Deutsch übersetzen, erst Englisch auswählen dann wieder Deutsch!

Google Android Playstore Download Button für Team IT Security



📚 VTable usage problem: How to set the expanded and collapsed state of the tree structure


💡 Newskategorie: Programmierung
🔗 Quelle: dev.to

Question title

How to set the expanded and collapsed state of the tree structure in a tree-structured table.

Problem Description

Through configuration, set the expanded and collapsed state of the tree structure table and customize the display style of the tree structure.

Solution

  1. hierarchyExpandLevel can be configured in the option of table initialization. This configuration item is defined as follows: When displayed as a tree structure, the number of levels is expanded by default. The default setting is 1 to display only the root node, and the configuration of Infinity will expand all nodes.

  2. You can also obtain the expanded and collapsed status of a certain cell through the API after the table is initialized, and set the expanded and collapsed status of a certain cell through the API.

    // Get the tree-shaped expanded or collapsed state of a certain cell
    getHierarchyState(col: number, row: number) : HierarchyState | null;
    enum HierarchyState {
      expand = 'expand',
      collapse = 'collapse',
      none = 'none'
    }
    
    // Header switch level status
    toggleHierarchyState(col: number, row: number): viod;
    

Code example

const option = {
  records:data,
  columns,
  widthMode:'standard',
  hierarchyExpandLevel: 2,
};
const tableInstance = new VTable.ListTable(container, option);

const state = tableInstance.getHierarchyState(0,1);
if (state === 'expand') {
    tableInstance.toggleHierarchyState(0,1);
}

Results display

Image description

Complete sample code (you can paste it into the editor to try it out):

let  tableInstance;
  fetch('https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/VTable/company_struct.json')
    .then((res) => res.json())
    .then((data) => {

const columns =[
    {
        "field": "group",
        "title": "department",
        "width": "auto",
         tree: true,
         fieldFormat(rec){
            return rec['department']??rec['group']??rec['name'];
         }
    },
    {
        "field": "total_children",
        "title": "memebers count",
        "width": "auto",
        fieldFormat(rec){
          if(rec?.['position']){
            return `position:  ${rec['position']}`
          }else
          return rec?.['total_children'];
        }
    },
    {
        "field": "monthly_expense",
        "title": "monthly expense",
        "width": "auto",
        fieldFormat(rec){
          if(rec?.['salary']){
            return `salary:  ${rec['salary']}`
          }else
          return rec?.['monthly_expense'];
        }
    },
    {
        "field": "new_hires_this_month",
        "title": "new hires this month",
        "width": "auto"
    },
    {
        "field": "resignations_this_month",
        "title": "resignations this month",
        "width": "auto"
    },
    {
        "field": "complaints_and_suggestions",
        "title": "recived complaints counts",
        "width": "auto"
    },

];

const option = {
  records:data,
  columns,
  widthMode:'standard',
  hierarchyExpandLevel: 2,
};

tableInstance = new VTable.ListTable(document.getElementById(CONTAINER_ID),option);
window['tableInstance'] = tableInstance;

const state = tableInstance.getHierarchyState(0,1);
if (state === 'expand') {
    tableInstance.toggleHierarchyState(0,1);
}
    })

Related documents

Tree mode demo:https://www.visactor.io/vtable/demo/table-type/list-table-tree

Related api:https://www.visactor.io/vtable/option/ListTable#hierarchyExpandLevel

github:https://github.com/VisActor/VTable

...



📌 VTable usage problem: How to set the expanded and collapsed state of the tree structure


📈 125.78 Punkte

📌 VTable usage issue: How to set the border style around cells separately


📈 40.97 Punkte

📌 VTable usage issue: How to set only one column to not be selected for operation


📈 40.97 Punkte

📌 VTable usage problem: How to display table row numbers


📈 40.75 Punkte

📌 Facebook Usage Has Collapsed After Privacy Scandals, Data Shows


📈 36.31 Punkte

📌 VTable usage issue: How to obtain the total number of rows in a table and the actual height of the content


📈 35.39 Punkte

📌 VTable usage issue: How to implement drag-and-drop adjustment of line-height


📈 35.39 Punkte

📌 VTable usage issue: How to listen to table area selection and cancellation events


📈 35.39 Punkte

📌 How to set the order in subnodes of a tree structure?


📈 34.03 Punkte

📌 VTable usage issue: How to implement hover to a cell to show or hide part of the content


📈 33.86 Punkte

📌 VTable usage issue: How to implement scrollbar DOM container boundary display


📈 33.86 Punkte

📌 VTable usage issue: How to make the table automatically calculate column width based only on the table header


📈 33.86 Punkte

📌 VTable usage issue: How to add column total information to the list


📈 33.86 Punkte

📌 How to dynamically set the min and max values of the progressBar type in the VTable component?


📈 31.77 Punkte

📌 Tree structure of glibc character sets and their aliases.


📈 28.45 Punkte

📌 C# - Flatter structure vs Nested structure


📈 28.15 Punkte

📌 Structure is Structure


📈 28.15 Punkte

📌 Let's Tree-Shake It... (aka Demystifying Tree-Shaking and Dead Code Elimination)


📈 27.21 Punkte

📌 Difference between Binary Search Tree and AVL Tree


📈 27.21 Punkte

📌 BST (Binary Search Tree) and AVL Tree, Data Structures: (Trees, Part II)


📈 27.21 Punkte

📌 iPhone Sales Collapsed in China and We All Know Why


📈 27.11 Punkte

📌 How do I modify state values in React with MobX-State-Tree?


📈 27.08 Punkte

📌 Foxit Quick PDF Library up to 16.11 Tree Structure LoadFromFile/LoadFromString/LoadFromStream memory corruption


📈 26.92 Punkte

📌 Introduction to Splay tree data structure


📈 26.92 Punkte

📌 Decision Tree Structure: A Comprehensive Guide


📈 26.92 Punkte

📌 Understanding Code Structure: A Beginner's Guide to Tree-sitter


📈 26.92 Punkte

📌 AZ: command launcher organised in a tree structure with autocompletion


📈 26.92 Punkte

📌 Medium CVE-2020-7682: Marked-tree project Marked-tree


📈 25.69 Punkte

📌 PE Tree - Python Module For Viewing Portable Executable (PE) Files In A Tree-View


📈 25.69 Punkte

📌 CTO (Call Tree Overviewer): yet another function call tree viewer


📈 25.69 Punkte

📌 Abstract Syntax Tree vs Parse Tree


📈 25.69 Punkte

📌 Christmas Tree 1.1.2 - A little Christmas tree, counting down the days to Christmas on your desktop.


📈 25.69 Punkte

📌 If You Bought a Real Christmas Tree, You Paid 15 Cents To the Christmas Tree Promotion Board


📈 25.69 Punkte











matomo