private void FillRights(Dictionary <int, Permission> storage, TreeViewCategory tree, Permission permission) { foreach (var categoryId in tree.GetCheckedNodes().Select(node => int.Parse(node.Value))) { storage[categoryId] = permission; } }
private void PopulateSubLevel(int parentid, TreeNode parentNode) { try { var myConnection = new SqlConnection(_connectionString); var objCommand = new SqlCommand(@"select ItemCategoryID,CategoryName , (select count(*) FROM matCategoryList WHERE ParentCategoryID=e.ItemCategoryID)+ (select count(*) FROM matMaterialSetup WHERE matMaterialSetup.ItemCategoryID=e.ItemCategoryID) AS childnodecount FROM matCategoryList e where ParentCategoryID=@ParentCategoryID UNION select ItemID AS ItemCategoryID ,ModelNo AS CategoryName,0 AS childnodecount FROM matMaterialSetup D where D.ItemCategoryID=@ParentCategoryID", myConnection); objCommand.Parameters.Add("@ParentCategoryID", SqlDbType.Int).Value = parentid; var da = new SqlDataAdapter(objCommand); var dt = new DataTable(); da.Fill(dt); PopulateNodes(dt, parentNode.ChildNodes); TreeViewCategory.CollapseAll(); } catch (Exception msgException) { throw msgException; } }
public void BindSubCategory(TreeViewCategory category) { var subcategory = (from c in _context.Categories where (c.ParentCategoryID == category.id) select new TreeViewCategory { id = c.CategoryID, title = c.CategoryName }); foreach (var item in subcategory) { BindSubCategory(item); category.subs.Add(item); } }
public void BindSubCategories(TreeViewCategory category) { var subCategoris = context.Categories.Where(c => c.ParentCategoryID == category.id).Select(c => new TreeViewCategory { id = c.CategoryID, title = c.CategoryName }).ToList(); foreach (var item in subCategoris) { BindSubCategories(item); category.subs.Add(item); } }
public void BindSubCategories(TreeViewCategory category) { var SubCategories = (from c in _context.Categories where (c.ParentCategoryId == category.id) select new TreeViewCategory { id = c.CategoryId, title = c.CategoryName, url = c.Url }).ToList(); foreach (var item in SubCategories) { BindSubCategories(item); category.subs.Add(item); } }
protected void btnUpdate_Click(object sender, EventArgs e) { try { AssignItemValuesForUpdate(); PanelItemDetails.Visible = false; clsTopMostMessageBox.Show(clsMessages.GProcessSuccess); btnUpdate.Visible = false; TreeViewCategory.ExpandAll(); } catch (Exception msgException) { clsTopMostMessageBox.Show(msgException.Message); } }
public void loadMenuChild(int parentID, TreeViewCategory <NewCategoryViewModel> res, List <TreeViewCategory <NewCategoryViewModel> > lstRes) { var modelChild = _newCategoryService.GetChildCategory(parentID); if (modelChild.Count() > 0) { var viewModel = Mapper.Map <List <NewCategory>, List <TreeViewCategory <NewCategoryViewModel> > >(modelChild.ToList()); res = lstRes.Find(x => x.Name == res.Name); res.Nodes = viewModel; foreach (var childItem in res.Nodes) { loadMenuChild(childItem.ID, childItem, res.Nodes); } } }
private void FillChild(string index, TreeNode tn)//fill up child nodes and respective child nodes of them { DataTable dt = new DataTable(); dt = GetProductCategoryByParentId(index); int i = 0; while (i < dt.Rows.Count) { TreeNode tn1 = new TreeNode(); tn1.Text = dt.Rows[i]["Category_Name"].ToString(); tn1.Value = dt.Rows[i]["Category_Id"].ToString(); tn.ChildNodes.Add(tn1); FillChild((dt.Rows[i]["Category_Id"].ToString()), tn1); i++; } TreeViewCategory.DataBind(); }
protected void btnSearch_Click(object sender, EventArgs e) { try { string valueForSearch = txtSearch.Text == string.Empty ? null : txtSearch.Text; TreeViewCategory.ExpandAll(); if (valueForSearch != null) { foreach (TreeNode t in TreeViewCategory.Nodes) { if (t.Text.ToUpper() == valueForSearch.ToUpper()) { t.Text = "<div style='color:orange;hight:15px'>" + t.Text + "</div>"; t.Selected = true; } for (int iParent = 0; iParent < t.ChildNodes.Count; iParent++) { if (t.ChildNodes[iParent].Text.ToUpper() == valueForSearch.ToUpper()) { t.ChildNodes[iParent].Text = "<div style='color:orange;hight:15px'>" + t.ChildNodes[iParent].Text + "</div>"; t.ChildNodes[iParent].Selected = true; } for (int iChild = 0; iChild < t.ChildNodes[iParent].ChildNodes.Count; iChild++) { if (t.ChildNodes[iParent].ChildNodes[iChild].Text.ToUpper() == valueForSearch.ToUpper()) { t.ChildNodes[iParent].ChildNodes[iChild].Text = "<div style='color:orange;hight:15px'>" + t.ChildNodes[iParent].ChildNodes[iChild].Text + "</div>"; t.ChildNodes[iParent].ChildNodes[iChild].Selected = true; } } } } } } catch (Exception msgException) { clsTopMostMessageBox.Show(msgException.Message); } }
//To apply tree view, delete options and BIN tab private void BindTreeView()//fucntion to fill up TreeView according to parent child nodes { TreeViewCategory.Nodes.Clear(); DataTable dt = new DataTable(); string x = "Parent_Id=" + "' '" + ""; dt = ObjProductCateMaster.GetProductCategoryTrueAllData(StrCompId); dt = new DataView(dt, x, "", DataViewRowState.OriginalRows).ToTable(); int i = 0; while (i < dt.Rows.Count) { TreeNode tn = new TreeNode(); tn.Text = dt.Rows[i]["Category_Name"].ToString(); tn.Value = dt.Rows[i]["Category_Id"].ToString(); TreeViewCategory.Nodes.Add(tn); FillChild((dt.Rows[i]["Category_Id"].ToString()), tn); i++; } TreeViewCategory.DataBind(); }
public HttpResponseMessage GetAll(HttpRequestMessage request) { var model = _newCategoryService.GetRootCategory(); var responseData = new TreeViewCategory <NewCategoryViewModel>(); var lstModel = new List <TreeViewCategory <NewCategoryViewModel> >(); foreach (var item in model) { var itemViewModel = Mapper.Map <NewCategory, NewCategoryViewModel>(item); responseData.ID = itemViewModel.ID; responseData.Name = itemViewModel.Name; responseData.Alias = itemViewModel.Alias; responseData.DisplayOrder = itemViewModel.DisplayOrder; responseData.ParentID = itemViewModel.ParentID; lstModel.Add(responseData); loadMenuChild(itemViewModel.ID, responseData, lstModel); responseData = new TreeViewCategory <NewCategoryViewModel>(); } //var responseData = Mapper.Map<IEnumerable<NewCategory>, IEnumerable<NewCategoryViewModel>>(model); return(request.CreateResponse(HttpStatusCode.OK, lstModel)); }
protected void TreeViewCategory_TreeNodePopulate(object sender, TreeNodeEventArgs e) { PopulateSubLevel(Int32.Parse(e.Node.Value), e.Node); TreeViewCategory.ExpandAll(); }