private void SetChildren(JsTreeJsonModel target, IEnumerable <JsTreeJsonModel> all) { if (all.Any(m => m.pid == target.id)) { target.children = all.Where(m => m.pid == target.id).ToList(); foreach (var child in target.children) { SetChildren(child, all); } } }
private void SetChildren(JsTreeJsonModel target, IEnumerable <JsTreeJsonModel> all) { if (all.Any(m => m.pid == target.id)) { target.children = all.Where(m => m.pid == target.id) .OrderBy(m => m.sort) .ThenBy(m => m.id) .ToList(); foreach (var child in target.children) { SetChildren(child, all); } target.icon = "fa fa-folder-open-o"; } else { target.icon = "fa fa-file"; } }