![]() |
obout treeview with checkbox
I am using Obout TreeView: www.obout.com
I would like to implement a page to add and remove categories to a product with the Obout Treeview with checkboxes. Does anyone allready did this and could help me with this?? Here is what I would like to do: -------------------------------- When the user selects a product, he can edit the categories for that product. So he goes to the page to edit the categories: On that page there is an 'Obout'-treeview with checkboxes. All categories where to the product belongs are checked. The treeview is generated from a dbase. It contains all categories from tbl_categories. (there are parent and child categories) So, now the user can uncheck or check more other categories. All this data is stored in the table tbl_productcategories: column1: productcategoryID (=autogeneratedID) column2: productID column3: categoryID An example of my treeview could be like this, but with a checkbox before every category: Cars - volvo - ford - others Computers - PC - Mac - others I hope you understand what I mean... There are lot's of ways to add a product to categories, but I think this-one is a very good one, because the user immediately sees all categories on a tree (so: parent and child categories), and he can check all the categories where the product should belong to. Really hope someone can help me with this. And, btw, I'm using Obout treeview, but if someone has a better idea, it's ofcourse welcome ! THX everyone, Nic |
Re: obout treeview with checkbox
I managed it on my own...
For those who could be interested, here's my code, well a part of it... --------stored procedure for insert-------- CREATE PROCEDURE spaddshopscats (@shopID int, @categoryID int) AS -- insert all the new selected categories INSERT INTO tbl_shopscats (shopID, categoryID) SELECT @shopID ,@categoryID Return GO -------------------------------------------- -------stored procedure for delete---------- CREATE PROCEDURE spdeleteshopscats @shopID int AS -- delete all the previous selected categories DELETE FROM tbl_shopscats WHERE tbl_shopscats.shopID = @shopID Return GO --------------------------------------------- ------------code on aspx-page---------------- <script runat="server"> Sub Page_PreRender(sender As Object, e As EventArgs) Dim html As String ' Classic style Dim oTree As New obout_ASPTreeView_2_NET.Tree() html = "<a class=ob_a href=""http://www.test.com"" target=""_main"">test</a>" oTree.Add("", "root", html, True) Dim poRec, psSQL, psParentID, psNodeID, psHTML, pbExpand, psImage ' Put correct path here. Dim ConnStr As String = ConfigurationSettings.AppSettings("ConnectionStrin g") Dim objConn As New SqlConnection(ConnStr) Dim daCat1 As New SqlDataAdapter("SELECT * FROM vw_shopscats ORDER BY categoryparentID, categorynameEN, categoryID" , objConn) Dim objDS As New DataSet daCat1.Fill(objDS, "dtCat1") Dim rowCat1 As DataRow For Each rowCat1 In objDS.Tables("dtCat1").Rows psNodeID = "A" & rowCat1("categoryID") psParentID = "A" & rowCat1("categoryparentID") dim ischecked as string = "" if rowCat1("shopID") is DBNull.Value then else if rowCat1("shopID") = request.querystring("shopID") then ischecked = "checked" end if end if 'if rowCat1("categoryparentID") <> 1 then 'fill datalist with products of the selected category psHTML = "<input type='checkbox' class='chk' id='" & rowCat1("categoryID") & "' name='chk_123' onclick='ob_t2send(this)'" & ischecked & "> " & rowCat1("categorynameEN") & "" 'psHTML = "<asp:CheckBox ID=chk_" & rowCat1("categoryID") & " runat=""server"" /> <a onclick='ob_t23(this)' class=lnkproduct href=""content_edit.aspx?categoryID=" & rowCat1("categoryID") & " "">" & rowCat1("categorynameEN") & "</a>" 'end if pbExpand = true 'is it expanded or not oTree.SelectedEnable = false 'psImage = "noimage.gif" If psParentID = "A1" Then psParentID = "root" End If oTree.Add(psParentID, psNodeID, psHTML, pbExpand, psImage) Next ' Put tree in label. 'oTree.TreeStyle_Path = "/tree/treeStyle_Iconless" oTree.FolderStyle = "/TreeIcons/Styles/Lines/Classic" oTree.ShowIcons = False oTree.Width = "300px" lblTree.Text = oTree.HTML() 'clean up objDS.Dispose() daCat1.Dispose() objConn.Close() objConn.Dispose() End Sub Sub insert_new_content (sender As Object, e As EventArgs) Dim MyConnectionString as String = ConfigurationSettings.AppSettings("ConnectionStrin g") Dim myConnection As SQLConnection myConnection = New SQLConnection(MyConnectionString) myConnection.Open() 'delete all the shopscats Dim myCommand0 As New SqlCommand("spdeleteshopscats", myConnection) myCommand0.CommandType = CommandType.StoredProcedure Dim Parameter0 As SqlParameter Parameter0 = New SqlParameter("@shopID", SqlDbType.Int, 4) Parameter0.Direction = ParameterDirection.Input Parameter0.Value = ctype(request.querystring("shopID"),integer) myCommand0.Parameters.Add(Parameter0) myCommand0.ExecuteNonQuery 'insert all the selected shopscats Dim i as integer Dim mycounter = ctype(chk_counter.text,integer) Dim MyString, MyArray MyString = categoryID.text MyArray = Split(MyString,",") For i=0 to mycounter-1 Dim myCommand As New SqlCommand("spaddshopscats", myConnection) myCommand.CommandType = CommandType.StoredProcedure Dim Parameter As SqlParameter Parameter = New SqlParameter("@shopID", SqlDbType.Int, 4) Parameter.Direction = ParameterDirection.Input Parameter.Value = ctype(request.querystring("shopID"),integer) myCommand.Parameters.Add(Parameter) Parameter = New SqlParameter("@categoryID", SqlDbType.Int, 4) Parameter.Direction = ParameterDirection.Input Parameter.Value = MyArray(i) myCommand.Parameters.Add(Parameter) myCommand.ExecuteNonQuery Next myConnection.Close() tblform.visible = false processing.visible=true lbldone.text = "Modifications done !" End Sub </script> --------------------------------------- ---------- code in the obout_treeview.js file -------- function ob_t2send() { // Make string with checked checkboxes IDs. var ob_t2in,ob_t2s,ob_t2send="",chk_counter=0; ob_t2in=document.getElementsByTagName("input"); for (var i=0; i<ob_t2in.length; i++) { ob_t2s=ob_t2in[i].id; if ((ob_t2in[i].checked)) { ob_t2send=ob_t2send+ob_t2s+","; chk_counter++ } } document.getElementById('categoryID').value=ob_t2s end; document.getElementById('chk_counter').value=chk_c ounter; } -------------------------------------------------------- So: I have 2 textboses on my page that are filled: one with the ID's and another-one with the amount of checked checkboxes. Hope it's a bit understandable...but it's better than nothing ENJOY "nicholas" <murmurait1@hotmail.com> wrote in message news:erV6xn%23yEHA.3236@TK2MSFTNGP15.phx.gbl... > I am using Obout TreeView: www.obout.com > I would like to implement a page to add and remove categories to a product > with the Obout Treeview with checkboxes. > > Does anyone allready did this and could help me with this?? > > Here is what I would like to do: > -------------------------------- > > When the user selects a product, he can edit the categories for that > product. > So he goes to the page to edit the categories: > On that page there is an 'Obout'-treeview with checkboxes. > All categories where to the product belongs are checked. > The treeview is generated from a dbase. It contains all categories from > tbl_categories. (there are parent and child categories) > So, now the user can uncheck or check more other categories. > All this data is stored in the table tbl_productcategories: > > column1: productcategoryID (=autogeneratedID) > column2: productID > column3: categoryID > > An example of my treeview could be like this, but with a checkbox before > every category: > > Cars > - volvo > - ford > - others > > Computers > - PC > - Mac > - others > > > I hope you understand what I mean... > There are lot's of ways to add a product to categories, but I think this-one > is a very good one, because the user immediately sees all categories on a > tree (so: parent and child categories), and he can check all the categories > where the product should belong to. > Really hope someone can help me with this. > And, btw, I'm using Obout treeview, but if someone has a better idea, it's > ofcourse welcome ! > THX everyone, > Nic > > |
| All times are GMT. The time now is 02:10 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.