Search code examples
tabulator

getRow for nested row


I have a table with nested datatree, I need to collapse particular rows but can't seem to get the row instance of the nested row. I can use the index of the top-level rows to do table.getRow(1) but table.getRow(2) fails. I can get the row instance of row 68 which is the next top-level row, so it seems I can't get row(2) because it is a child of row(1). is there an alternate way to get child rows? table.getRow(1).getRow(2)?


Solution

  • Check documentation check this jsfiddle and check console

    use `var children = row.getTreeChildren();`
    
    // Get all rows
     const allRows = table.getRows();
      console.log('allRows',allRows);
    
     const firstRow = table.getRow(1);
      console.log('firstRow',firstRow);
    
    const firstRowChildren =  firstRow.getTreeChildren();
      console.log('firstRowChildren',firstRowChildren);
    
    
    $('#toggle').click(function(){
    firstRow.treeToggle();
    });