server/models/helpers/component-from-model.js
function(modelData, scContent) {
      if (scContent['treeData']) {
        // this data must be represented as hierarchical data (tree)
        let parentColumn = scContent.treeData.parentColumn;
        let rootParent = (scContent.treeData['root'])?scContent.treeData['root']:0;
        let childColumn = scContent.idColumn;
        // keep track of deepest level
        scContent.treeData['deepestLevel'] = 0;
        let orderStart = 1;

        function sortData(all, top, data, sort, level) {
          if (level > scContent.treeData['deepestLevel']) {
            scContent.treeData['deepestLevel'] = level;
          }
          _.forEach(_.filter(all, [parentColumn, top]), function(val) {
            val = val.toJSON();
            val['treeDisplayOrder'] = sort;
            val['treeLevel'] = level;
            data.push(val);
            // check if have children
            if (_.find(all, [parentColumn, val[childColumn]])) {
              data = sortData(all, val[childColumn], data, orderStart, (level + 1));
            }
            sort++;
          });
          return data;
        }
        return sortData(modelData, rootParent, [], orderStart, 0);
      }
      else {
        var data = [];
        _.forEach(modelData, function(val) {
          data.push(val.toJSON());
        });
        return data;
      }
    }
function(modelData, scContent) {
      if (scContent['treeData']) {
        // this data must be represented as hierarchical data (tree)
        let parentColumn = scContent.treeData.parentColumn;
        let rootParent = (scContent.treeData['root'])?scContent.treeData['root']:0;
        let childColumn = scContent.idColumn;
        // keep track of deepest level
        scContent.treeData['deepestLevel'] = 0;
        let orderStart = 1;

        function sortData(all, top, data, sort, level) {
          if (level > scContent.treeData['deepestLevel']) {
            scContent.treeData['deepestLevel'] = level;
          }
          _.forEach(_.filter(all, [parentColumn, top]), function(val) {
            val = val.toJSON();
            val['treeDisplayOrder'] = sort;
            val['treeLevel'] = level;
            data.push(val);
            // check if have children
            if (_.find(all, [parentColumn, val[childColumn]])) {
              data = sortData(all, val[childColumn], data, orderStart, (level + 1));
            }
            sort++;
          });
          return data;
        }
        return sortData(modelData, rootParent, [], orderStart, 0);
      }
      else {
        var data = [];
        _.forEach(modelData, function(val) {
          data.push(val.toJSON());
        });
        return data;
      }
    }
load data from model for datatable Component