Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > obout treeview with checkbox

Reply
Thread Tools

obout treeview with checkbox

 
 
nicholas
Guest
Posts: n/a
 
      11-16-2004
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


 
Reply With Quote
 
 
 
 
nicholas
Guest
Posts: n/a
 
      11-17-2004
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" <(E-Mail Removed)> wrote in message
news:erV6xn%(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
obout menu components Patrick.O.Ige ASP .Net 1 09-23-2013 11:38 AM
Anyone has tried OBOUT?. jc ASP .Net 1 09-23-2013 11:23 AM
Anyone use obout controls? Bobby Edward ASP .Net 8 01-07-2013 02:28 PM
Obout Suite Support gotech ASP .Net Web Controls 0 02-21-2012 08:06 PM
Obout Tree View - Node Vertical/Horizontal Spacing ? quantass ASP .Net 1 01-21-2007 12:04 PM



Advertisments