OnToggle function in TreeTable in Prime React 10.1.1 doesn't work correctly

81 Views Asked by At

I'm using PrimeReact 10.1.1 and want to implement TreeTable. However, when I use onToggle function, I always get undefined value in the event. What could be the possible solutions? I don't have any other side function, which can overwrite the logic and etc. I will be very grateful, if you could help me out When I click on the expander and log the event in the console, I always get value: {undefined: true} Interesting is that onRowExpand works fine

I tried with dummy data to check if it is something from the types, many times debugging, checked documentation for TreeTable in Prime React 10.1.1

This is my onToggle func:

const onToggle = (event) =>
    {
     console.log("onToggle", event);
      setExpandedRows(event.value)
    };

return <>
        <Helmet>
            <title>Monitoring | TCM</title>
        </Helmet>
        <section>
            <TreeTable
                value={monitoringStore.periods}
                id={MonitoringFields.TABLE_ID}
                sortMode="multiple"
                lazy
                onRowExpand={onRowExpand}
                onToggle={(e) => onToggle(e)}
                onRowCollapse={onCollapse}
                expandedRows={expandedRows}
                // key={Math.random()}
                rows={monitoringStore.queryParams.rows}
                first={monitoringStore.queryParams.first}
                totalRecords={monitoringStore.totalCount}
                onPage={(e) => onPageChange(e)}
                onSort={(e) => onPageChange(e)}
                paginator
                columnResizeMode='expand'
            >
                {getExpandColumn(MonitoringFields.TABLE_ID)}
                {getDynamicColumns({
                columnsData: monitoringTableData[0].items,
                tableId: MonitoringFields.TABLE_ID,
                queryParams: monitoringStore.queryParams,
                handlers: null,
                tableName: TableNames.MONITORING_TABLE,
              })}
            </TreeTable>

        </section>
    </>
    
})

in the onToggle func event.value is always equals to {undefined: true}

0

There are 0 best solutions below