public JsonResult GetChildren(string id)
        {
            var items = new List <NewJSTreeVM>();

            {
                NewJSTreeVM model = new NewJSTreeVM()
                {
                    id       = "2",
                    text     = "Root node",
                    children = new List <JsTreeViewModel>()
                    {
                        new JsTreeViewModel()
                        {
                            id = "4", text = "Child Node 1", children = true
                        },
                        new JsTreeViewModel()
                        {
                            id = "5", text = "Child Node 2", children = true
                        },
                    }
                };

                items.Add(model);
            }
            // set items in here
            var dataa = JsonConvert.SerializeObject(items);

            return(Json(items));
        }
        public JsonResult GetRoot(string id)
        {
            var         items      = new List <NewJSTreeVM>();
            NewJSTreeVM rootModel  = new NewJSTreeVM();
            string      parentId   = string.Empty;
            bool        isChildren = false;


            if (id.Contains("##"))
            {
                parentId   = id;
                isChildren = true;
                id         = id.Split("##")[1];
            }

            DataTable dt = _partService.GetTreeViewData(id);

            if (dt != null && dt.Rows.Count > 0)
            {
                if (!isChildren)
                {
                    rootModel = new NewJSTreeVM()
                    {
                        id       = dt.Rows[0]["parentPartId"]?.ToString(),
                        text     = dt.Rows[0]["parentName"]?.ToString(),
                        children = new List <JsTreeViewModel>()
                    };
                }
                else
                {
                    rootModel = new NewJSTreeVM()
                    {
                        id       = parentId,
                        text     = dt.Rows[0]["parentName"]?.ToString(),
                        children = new List <JsTreeViewModel>()
                    };
                }

                foreach (var rows in dt.Select("LEVEL = '0'"))
                {
                    string text = string.Empty;
                    if (dt.Select("parentPartId = '" + rows["childPartId"]?.ToString() + "'").Any())
                    {
                        text = dt.Select("parentPartId = '" + rows["childPartId"]?.ToString() + "'").FirstOrDefault()["parentName"]?.ToString();
                    }
                    else
                    {
                        text = _partService.GetPartById(Convert.ToInt32(rows["childPartId"]?.ToString()))?.PartName;
                    }

                    rootModel.children.Add(new JsTreeViewModel()
                    {
                        id       = dt.Rows[0]["parentPartId"]?.ToString() + "##" + rows["childPartId"]?.ToString() + "##",
                        children = dt.Select("parentPartId = '" + rows["childPartId"]?.ToString() + "'").Any() ? true : false,
                        text     = text
                    });
                }
            }
            else
            {
                rootModel = new NewJSTreeVM()
                {
                    id       = id,
                    text     = "No Part",
                    children = null
                };
            }

            items.Add(rootModel);

            return(Json(items));
        }