JSFiddle - React, Tailwind, and code Playground

by nithyanandam venu

JavaScript

function getDataSourceNodes() {
        let rowDim;
        
          var props={
   				"derivedTreeConfig":
      		"deriveTreeFromSource":
          "dynDataNodes":
          "maxChild":
          "nodesExceededMaxChild":
   				}

/*         console.log(props.derivedTreeConfig);
        console.log(props.deriveTreeFromSource);
        console.log(props.dynDataNodes);
        console.log(props.maxChild);
        console.log(props.nodesExceededMaxChild); */

        
        const withDerivedChildren = props.derivedTreeConfig.reduce((nodes, config, i) => {
            if (config.deriveChildren && config.cMeth == "") { // Ignore derived config if node is not from Source
                nodes.push({ config: config, index: i })
            }
            return nodes
        }, []); 

        if (!withDerivedChildren.length) {
            return;
        }

        props.deriveTreeFromSource = true;
        props.nodesExceededMaxChild = {};

        if(props.dynDataNodes.length) {
            rowDim = props.dynDataNodes;

            // Change the configuration of the nodes based on the source:
            $.each(withDerivedChildren || [], (i, node) => {
                let tmpl = props.derivedTreeConfig[node.index];
                tmpl.cMeth = tmpl.derivedSim == 'P' ? '' : 'A' // Make the node aggregate the children
                tmpl.locked = tmpl.level == 0 ? 'X' : (!tmpl.derivedSim ? '' : 'X')
            })

            // We now have all the rows in the right order and can now enrich the tree config where they belong:
            for (let j = withDerivedChildren.length - 1; j >= 0; j--) {
                const node = withDerivedChildren[j];
                const tmpl = node.config;
                let level = -1;
                const children = [];
                const maxChildMap: any = {};               
                for (let i = 0; i < rowDim.length; i++) {
                    var d = rowDim[i];
                    const nextRow = rowDim[i + 1] ||...