Click here to Skip to main content
Click here to Skip to main content

I3HTree – Html Tree + Html Grid Web Control

By , 23 Aug 2004
 

Latest Update

Release 0.22

This version adds a new control setting (I3HGridSaveStyle) that let you decide if the OnGridItemsValueChange event is fired only when a page submit is invoked or whenever a control value is changed. The latter option allows you to change the value of any cell of the grid when the user edits a cell value (for instance in the MyOrderForm sample the row total cell changes whenever the user edits the quantity text box).

In addition it fixes an annoying bug related to the use of the control inside a C# project. To solve it I had to change the name of the control that now is I3HTreeCtrl.I3HTree.

See History section below for further details.

Introduction

This article presents the new version of I3HTree control; the first version can be found in a previous article:

I created a new article instead of updating the previous because this new release of the control is completely different from the first one. I consider the first release of I3HTree a kind of experiment, from that I started developing this new version adding new features and changing some of the exiting. I also re-organized (and re-named) the interface methods for cleaning reasons.

Now I feel that the control has a cleaner architecture and I can build up new functions on it without changing the base anymore (or at least without any deep impact on existing interfaces).

One of the biggest improvement was integrating an Html Data Grid with the Html Tree as shown in the next picture.

The main idea of the control is still the same: the data are requested only when the related tree nodes or grid rows have to be shown; the ability of loading the data just when needed makes the I3HTreeCtrl suitable when a very large data tree is present.

The data request occurs via an Event fired by the I3HTreeCtrl Web Control. Basically the ASP.NET application that uses the I3HTreeCtrl control just needs to handle a set of events depending on the control style he wants to use; for instance the OnShowTreeFolders and the OnShowTreeItems events request respectively the tree folders and the tree items (leaves) node under a specific parent node.

A caching mechanism (optional) is foreseen to avoid requesting the same data more than once.

Tree styles

Standard Tree Style

The Standard Style consists of a standard Html Tree. The Tree is made up by Folders and Tree Items.

A Folder is represented by a key (unique), a caption, images (when the folder is open, close or empty) and css styles (when the folder is selected or not). A folder can be expanded and collapsed. A Tree Item is represented by a key (unique), a caption, an image, a link (url and target) and css styles (when the folder is selected or not).

Check-Box Tree Style

The Check-Box Style consists of an Html Tree with a check-box control associated to each tree item. The check-box is implemented using the Html input tag; this means that the tree items can be checked and/or unchecked without reloading the page. In addition an image can be still associated to each item.

Explorer Style

The Explorer Style consists of an Html Tree control plus an Html Grid control. The format (columns number and style) and the data depend on the selected folder in the tree.

Each time a folder is selected the grid is refreshed. As for the Html Tree the Html Grid has and integrated caching mechanism. The Html Grid supports different column types: normal (any Html code, typically a simple text), link, image, image link, check-box, text-box, combo-box.

I3HTreeCtrl class

It is the class that represents the Html Web Control; it inherits from System.Web.UI.WebControls.WebControl and it implements the IPostBackEventHandler interface.

Properties

  • I3HTreeStyle

Set the tree style:

  • eTreeNormal
  • eTreeCheckBox
    The control requires all data the first time it is loaded.
  • eTreeExplorer
    Html Tree plus Html Grid.
  • I3HLoadStyle

Defines the loading style of the control:

  • eLoadWhenExpand (default)
    The control requires tree nodes data only when it needs it that is the user opens a node and wants to displays it children.
  • eLoadAll
    The control requires all data the first time it is loaded.
  • I3HCacheStyle

Enable/disable the control cache:

  • eCacheEnabled (default)
    Each node is requested only once.
  • eNoCache
    The control fires the node data request each time the node is shown.
  • I3HTreeOrderStyle

Set the tree order style:

  • eTreeFoldersItems
    Folders are displayed before items.
  • eTreeItemsFolders
    Items are displayed before folders.
  • I3HTreeSelectStyle

Set the tree selection style:

  • eTreeSelectNormal
    Clicking on the folder icon causes the sub-tree to expand or collapse while clicking on the folder name causes the folder to be selected (the selected style applies).
  • eTreeSelectCollaspeExpand
    With this style clicking the folder name causes the sub-tree to expand or collapse.
  • I3HRootOpenImage
Set the image file to be shown when the root node is expanded.
  • I3HRootCloseImage
Set the image file to be shown when the root node is collapsed.
  • I3HFolderOpenImage
Set the image file to be shown when any folder node is expanded.
  • I3HFolderCloseImage
Set the image file to be shown when any folder node is collapsed.
  • I3HFolderEmptyImage
Set the image file to be shown when a folder contains no items.
  • I3HItemDefaultImage
Set the image file to be shown by default when an item node has to be shown; it is possible to specify a different image for each item, it no image is specified the default is then used.
  • I3HCssTableStyle
Css style of the main table that contains both the Html Tree and the Html Grid.
  • I3HCssTreeTableStyle
Css style of the Html Tree table.
  • I3HCssGridTableStyle
Css style of the Html Grid table.
  • I3HCssTDFolderStyle
Default Css style of a Folder table cell.
  • I3HCssAFolderStyle
Default Css style of a Folder link.
  • I3HCssAFolderSelectedStyle
Default Css style of a selected Folder link.
  • I3HCssTDItemStyle
Default Css style of an Item table cell.
  • I3HCssAItemStyle
Default Css style of an Item link.
  • I3HCssAItemSelectedStyle
Default Css style of a selected Item link.
  • I3HRootKey
Key of the root node.
  • I3HRootCaption
Caption of the root node.

Methods

  • GetSubmitUrl

Returns the Url that has to call in order to force the saving process of the Html Grid form controls.

  • GetTreeObject

Returns the I3HTree object.

Events

  • OnShowTreeFolders
Fires when the tree control needs folders information. The parent node key is provided.
The called component has to fill some arrays with children folders keys and captions.
  • OnShowTreeItems

Fires when the tree control needs items information. The parent node key is provided.
The called component has to fill some arrays with children items keys and captions.

  • OnShowGridItems

Fires when a tree folder is selected in the Explorer style. The parent node key is provided. The called component has to fill the array with the children item keys.

  • OnShowGridItemValue

Fires when a normal cell has to be filled.

  • OnShowGridItemLinkValue

Fires when a link cell has to be filled.

  • OnShowGridItemImageValue

Fires when an image cell has to be filled.

  • OnShowGridItemImageLinkValue
Fires when an image link cell has to be filled.
  • OnShowGridItemCheckValue
Fires when a check-box cell has to be filled.
  • OnShowGridItemTextValue
Fires when a text-box cell has to be filled.
  • OnShowGridItemComboValue
Fires when a combo-box cell has to be filled.
  • OnTreeItemsCheckChange
Fires on the page postback providing the list of nodes that have been checked or unchecked.
  • OnGridItemsValueChange
Fires on the page postback providing the list of node values that have been changed.
  • OnSelectChange
Fires when the selected node changes.
  • OnNodeCollaspe
Fires when a node is collapsed.
  • OnNodeExpand
Fires when a node is expanded.

CI3Tree class

It is the main object where the Html Tree and Html Grid formats and data are stored.

Methods

  • GetSelectedNodeKey

Returns the current selected node key.

  • GetSelectedNodeCaption

Returns the current selected node caption.

  • SelectNode

Select a Node; it causes the tree to expand in order to make the node visible. The methods works only with node that have been already loaded.

  • GetNodeCaption

Returns the node caption of the requested node.

  • SetNodeCaption

Change the node caption of the requested node.

  • IsItemChecked

Returns whether the requested item is checked or not.

  • CheckItem

Check the requested item.

  • GetCheckedItemList

Returns an array of all the currently checked items.

  • ClearCheckItemList

Un-checks all the items.

  • ClearTreeNodes

Clear all the tree nodes.

  • AddRoot

Add a root node to the tree.

  • AddFolder

Add a folder node to the tree.

  • AddTreeItem

Add a tree item node to the tree.

  • DeleteNode

Delete a node from the tree.

  • FindNode

Retrieve a node object giving its key.

  • AddGridType

Add a grid definition.

  • FindGridType

Retrieve a grid type giving its key.

CI3Node class

It represents a generic Html Tree node; it is the base class of all other Html Tree classes: CI3Folder, CI3ItemTree, CI3ItemGrid.

Properties

  • Key
Unique node key.
  • Caption
Node caption.
  • Level
Tree hierarchical level (1 is the root, 2 the first level children, and so on).
  • Parent
Reference to the parent node.
  • Tree
Reference to CI3Tree object.

Methods

  • SelectNode

Selects the node.

  • GetItemData

Returns the internal object related to the tree node.

  • SetItemData

Sets a data object to be associated with the tree node.

CI3Folder class

It represents an Html Tree folder; a folder contains tree items and can be expanded and collapsed.

Properties

  • Expanded
Returns the expanded or collapsed state.

Methods

  • CollapseNode

Collapse the folder.

  • ExpandNode

Expand the folder.

CI3ItemTree class

It represents an Html Tree item; an item can be configured with an image and/or a link to a Url (href + target).

Properties

  • Image
Image file associated.
  • HRef
HRef of the link.
  • Target
Target of the link.

Methods

  • IsChecked

Only for Check-Box style. Return true if the item is currently checked.

  • CheckNode

Only for Check-Box style. Check or uncheck the node.

CI3ItemGrid class

It represents an Html Grid item. The grid item corresponds to a row of the Html Grid; it stores the value for each grid column.

Methods

  • AddItemValue

Add a new CI3ColValue object that represents the value of a specific grid cell.

  • GetItemValue

It retrieves a reference to the CI3ColValue object that represents the value of a specific grid cell.

CI3Grid class

It represents an Html Grid. The I3HTree control supports different grid formats, one per each tree folder.

Properties

  • GridTypeId
String that identifies the grid type.
  • Cols
Returns the grid columns collection.
  • Caption
Grid caption.
  • CSSCaptionStyle
Grid caption Css style.

Methods

  • AddColumn

Add a column header definition to a specific grid.

  • ClearColumns

Clear all columns.

CI3ColHeader class

It represents the definition of a column of the Html Grid.

Properties

  • No
Column index.
  • HeaderText
Column header text.
  • ColumnType
Column type: normal, link, image, image link, text-box, combo-box, check-box.
  • HeaderType
Header type, normal, sort.
  • TDWidth
Column width.
  • TDCssStyle
Column Css style.

Methods

  • AddComboItem

Add a combo-box item to a column (of combo-box type).

  • EnumComboItem

Initialize the combo-box items enumerator.

  • GetNextComboItem

Retrieve a combo-box item from the enumerator.

  • ClearComboItems

Clear the combo-box items.

CI3ColValue class

It represents a data grid cell value.

Properties

  • ColNo
Index of the related column.
  • ColHeader
Column type of the related column.

Methods

  • GetValue

Returns the cell value for any cell type.

  • GetDisplayValue

Returns the cell display value. The display value can be used for formatting fields like currencies or date.

  • SetValue

Set the Value and the Display Value of a cell.

  • GetLink

Returns the cell value for link and image-link styles.

  • SetLink

Sets the cell value for link and image-link styles.

  • GetImage

Returns the cell value for image and image-link styles.

  • SetImage

Sets the cell value for image and image-link styles.

  • SetStyle

Sets the Css styles.

How to use the I3HTreeCtrl

Setting styles and attributes


Using the I3HTreeCtrl is very simple. You just need to add a reference to the I3HTreeCtrl.dll in your project; then a new icon will be shown in the Web Forms toolbox. Then you can simply drag & drop the control in a Web Form.

Once you have done, a code line similar to the following shall appear in the "Web Form Designer Generated Code" region.

Protected WithEvents i3htree As I3HTreeCtrl.I3HTreeCtrl

In the Page_Load event handler method you can set any control property for deciding the tree behavior or for changing default CSS styles or images. For instance:

i3htree.I3HRootCaption = "my products"<br>i3htree.I3HRootKey = "MyRootKey"<br>i3htree.I3HTreeStyle = I3HTreeCtrl.I3HTreeCtrl.enumTreeStyle.eTreeCheckBox

The layout of the tree can be changed acting on the css styles and on the images. The page you are working on shall include a css file:

<LINK href="i3htree.css" type="text/css" rel="stylesheet">

The file contains the styles related to the tree objects that are defined in the control properties.

Creating the tree

To create the tree you need to put your code in the IH3TreeCtrl two main event handlers: OnShowFolders<CODE> and OnShowTreeItems. The folders are tree nodes that can be expanded and collapsed while the items are the leaves of the tree.

OnShowTreeFolders(ByVal sParentKey As String, _
                  ByRef aKey As System.Collections.ArrayList, _
                  ByRef aCaption As System.Collections.ArrayList, _
                  ByRef aTDClass As System.Collections.ArrayList, _
                  ByRef aAClass As System.Collections.ArrayList, _
                  ByRef aASelectedClass As System.Collections.ArrayList) _
                  Handles i3htree.OnShowTreeFolders

This method is called when the user expands a sub-tree under the node identified by the sParentKey string. The first time the method is call using the root key (by default is ROOT but it can be changed using the I3HRootKey property).

The called application shall fill the aKey, aCaption, aTDClass, aAClass, and aSelectedClass arrays. The aKey values will be used in the subsequent OnShowFolder and OnShowTreeItems events while aCaption values are the displayed tree node descriptions. The aTDClass, aAClass, and aSelectedClass arrays specify the css style to be used for the table cell (<td> tag), the link (<a> tag) and the link when the folder is selected.

OnShowTreeItems(ByVal sParentKey As String, _
                ByRef aKey As System.Collections.ArrayList, _
                ByRef aCaption As System.Collections.ArrayList, _
                ByRef aImage As System.Collections.ArrayList, _
                ByRef aLink As System.Collections.ArrayList, _
                ByRef aTarget As System.Collections.ArrayList, _
                ByRef aTDClass As System.Collections.ArrayList, _
                ByRef aAClass As System.Collections.ArrayList, _
                ByRef aASelectedClass As System.Collections.ArrayList) _
                Handles i3htree.OnShowTreeItems
For each item the called applications can specify the key, the caption, the image (if it differs from the default images specified in the tree properties), the link address, and the link target.

Using the CheckBox Style

The CheckBox style let associated a check-box to each Tree Item. The control stores the checked items, to get the list at any time use the GetCheckedItemList method and to free the list use the ClearCheckedItemList method.

A single item can be checked, unchecked using the CheckItem method.

Defining grid columns

When the Explorer Style is set it is possible to define grid columns as shown in the following code:

Dim col As I3HTreeCtrl.CI3ColHeader
Dim sTypeId As String = "coltypeproducts"
<br>col = New I3HTreeCtrl.CI3ColHeader(sTypeId, _
                0, _
                "", _
                I3HTreeCtrl.CI3Tree.enumColumnType.eColImage, _
                I3HTreeCtrl.CI3Tree.enumHeaderType.eHeaderNormal, _
                "50", _
                "i3hTDHeader")<br>i3htree.GetTreeObject().AddColumn(col)

The first parameter sTypeId allows grouping columns that belong to the same Html Grid. The control allows defining different grids so that it is possible to associate a different grid for different Tree Folder.

Other column attributes are: the position, the header, the type (normal, image, image link, link, text-box, check-box, combo-box), the header style (normal or sort), the width, and the css style.

Creating the grid

The grid is created handling the OnShowGridItems and the OnShowGridItemXValue.

The OnShowGridItems is fired when a folder on the tree is selected.

OnShowGridItems(ByVal sParentKey As String, _
  ByRef sGridTypeId As String, _
  ByRef aKey As System.Collections.ArrayList) _
  Handles i3htree.OnShowGridItems


The application that handles the method provides the grid type (in this way the grid columns are defined) and the array of item keys (in this way the grid rows are defined). Then the control fires the OnShowGridItemXValue for each grid cell depending on the columns type. The complete list of methods is:

  • OnShowGridItemValue()
  • OnShowGridItemLinkValue()
  • OnShowGridItemImageValue()
  • OnShowGridItemImageLinkValue()
  • OnShowGridItemTextValue()
  • OnShowGridItemComboValue()

Saving user edited data

The data that the user may edit using the grid controls (text-box, check-box, combo-box) are automatically saved on each PostBack event (for instance when the tree selection is changed). In addition the saving process can be forced; to this aim the control provides a GetSubmitUrl method. The submit Url can be assigned to an hyperlink control in the following way:

hypUpdate.NavigateUrl = i3htree.GetSubmitUrl

In this way by clicking on the hypUpdate link the user forces the saving process.

MyOrderForm Sample application

The MyOrderForm application is a sample application that shows how to use the I3HTreeCtrl with the Explorer style.

The application shows an Html Tree representing a products catalog; each tree folder represents a product category and by selecting a folder the Html Grid shows the products (image, code, name, price, size, and quantity are provided). To order the user has to set the quantity of the product he wants to order.

In the Page_Load events the control attributes are set and the grid columns are defined. The code has to be executed only once so it has to be skipped when the load event is triggered by a PostBack.

If Not Me.IsPostBack Then

   'just the first time
   'set the tree attributes

   i3htree.I3HRootCaption = "my products"
   i3htree.I3HTreeStyle = I3HTreeCtrl.CI3Tree.enumTreeStyle.eTreeExplorer
   i3htree.I3HTreeSelectStyle =
      I3HTreeCtrl.CI3Tree.enumTreeSelectStyle.eTreeSelectExpand

   'create the grid columns

   Dim sTypeId As String = "coltypeproducts" 'typeId is always the same!
   Dim col As I3HTreeCtrl.CI3ColHeader
       
   col = New I3HTreeCtrl.CI3ColHeader(sTypeId, _
               0, _nbsp;           0, _
               "", _
               I3HTreeCtrl.CI3Tree.enumColumnType.eColImage, _
               I3HTreeCtrl.CI3Tree.enumHeaderType.eHeaderNormal, _
               "50", _
               "i3hTDHeader")
               i3htree.GetTreeObject().AddColumn(col)
   ...
   ...
   ...
   'add combo column
   col = New I3HTreeCtrl.CI3ColHeader(sTypeId, _
               4, _nbsp;           4, _
               "size", _
               I3HTreeCtrl.CI3Tree.enumColumnType.eColComboBox, _
               I3HTreeCtrl.CI3Tree.enumHeaderType.eHeaderNormal, _
               "5%", _
               "i3hTDHeader")
           
   i3htree.GetTreeObject().AddColumn(col)
   col.AddComboItem(1, "small")
   col.AddComboItem(2, "medium")
   col.AddComboItem(3, "large")
End If

Once the tree and grid attributes have been defined the I3HTreeCtrl fires events when data is needed according to the user actions.

The tree is created by handling the OnShowTreeFolders event; note that using the Explorer style the OnShowTreeItems will never be called.

Private Sub i3htree_OnShowTreeFolders(ByVal sParentKey As String, _
  ByRef aKey As System.Collections.ArrayList, _
  ByRef aCaption As System.Collections.ArrayList, _
  ByRef aTDClass As System.Collections.ArrayList, _
  ByRef aAClass As System.Collections.ArrayList, _
  ByRef aASelectedClass As System.Collections.ArrayList) _
  Handles i3htree.OnShowTreeFolders;
 
   Handles i3htree.OnShowTreeFolders

   Dim nParentID As Int32

   If sParentKey = "ROOT" Then
      nParentID = 0
   ElseIf sParentKey.Chars(0) = "C" Then
      nParentID = Convert.ToInt32(sParentKey.Substring(1))
   Elsenbsp; Else
      Return
   End If

   Dim cnt As New OleDb.OleDbConnection
   cnt.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;
     Data Source=" + System.Web.HttpRuntime.AppDomainAppPath +
     "MyOrderForm.mdb"
   cnt.Open()

   Dim ds As Data.DataSet = New Data.DataSet
   Dim adp As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter

   'get topics listopics list
   adp.SelectCommand = New OleDb.OleDbCommand
   adp.SelectCommand.CommandText =
"SELECT * FROM tblTree WHERE ParentID = " & nParentID
   adp.SelectCommand.Connection = cnt
   adp.Fill(ds)

   Dim rows As DataRowCollection = ds.Tables(0).Rows
   Dim row As DataRow

   For Each row In rows
      aKey.Add("C" & Convert.ToString(row("ID")))
      aCaption.Add(row("Category"))
   Next

   cnt.Close()
End Sub

The grid is created by handling the OnShowGridItems event; in the event handler method the grid rows number is set. Then the I3HTreeCtrl fires an event per each grid cell according to the cell type (so for instance it fires the OnShowGridItemValue for standard cells, the OnShowGridItemImageValue for image cells, and so on).

The data edited by the user are saved back to the database by handling the OnGridItemsValueChange method.

Private Sub i3htree_OnGridItemsValueChange(
  ByRef aKey As System.Collections.ArrayList, _
  ByRef aCol As System.Collections.ArrayList, _
  ByRef aNewValue As System.Collections.ArrayList) _
  Handles i3htree.OnGridItemsValueChangesp;                           
 Handles i3htree.OnGridItemsValueChange

   Dim i As Int32

   For i = 0 To aKey.Count - 1
      Dim sKey As String = aKey(i)
      Dim nCol As Int32 = aCol(i)
      Dim oValue As Object = aNewValue(i)

      'save to database;  'save to database
      '...
   Next

End Sub

History

To get the latest version

I will post any major version on CodeProject; if you wish to get the code of latest version of the I3HTree just visit www.intre.it/osp.

Release R0.22 (22-Ago-2004)

NOTE:

The control changes its name from I3HTreeCtrl to I3HTree.For existing projects you shall make the following changes:

  • In all .vb files you shall change all the declarations from
    Protected WithEvents i3htree As I3HTreeCtrl.I3HTreeCtrl
    to
    Protected WithEvents i3htree As I3HTreeCtrl.I3HTree
  • In all .aspx files you shall change all the declarations from
    <cc1:I3HTreeCtrl id="i3htree" runat="server"></cc1:I3HTreeCtrl>
    to
    <cc1:I3HTree id="i3htree" runat="server"></cc1:I3HTree>

Fixed bugs:

  • Fixed compilation error that occured when trying to use the component inside a C# project.

New features:

  • Added enumGridSaveStyle style. This allow to have a postback anytime a control value (textbox, combobox, checkbox) is changed without having to wait the page submit. This is useful if a cell modification has to trigger another cell modification.
  • Changed OnShowGridItemValue and OnShowGridItemTextValue events to support value and display value for handling formatted field like currencies, date, and so on.

Misc changes:

  • Class CI3Node, added Tree public property.
  • Class CI3ColValue, GetDisplayValue, GetValue, and SetValue methods.

Release R0.21 (09-Jul-2004)

Fixed bugs:

  • Tree node item does not create correctly if target attribute is set.
  • If more that one grid type is defined the grid columns headers are wrong; to solve the problem and to simply the columns management a new class (CI3Grid) has been added to group column headers.

New features:

  • Added ability to set the Grid caption

Release R0.20 (02-Jul-2004)

First release.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

big71
Web Developer
Italy Italy
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionHow to reload tree with different information???memberaltarribage2 Oct '07 - 1:10 
I've a little problem. I need to reload the tree with different information, depending input information.
 
I don't know how to clear i3htree nodes and the root caption node. I have discovered that the class cI3Tree can execute the procedure ClearTreeNodes, but I don't know how to clear the cI3Tree from my i2HTree.
 
Somebody have any clue of it??
 
Thank you very much
 
gemma
GeneralC# 2.0 versionmemberRodrigoAntunes17 Apr '07 - 10:46 
Hi there,
is there any version of this checkbox tree in C# .NET 2.0 ?
my contact is danzka@netcabo.pt
thanks
GeneralRaisePostBackEvent never calledmemberjim_kanepele25 Jul '05 - 2:02 
Hi,
 
I'm using your version 0.23 to display a treeview with checkboxes next to the items.
When I use 'eSaveOnSubmit', it seems like the RaisePostBackEvent is never called.
Subsequently when I request for a list of checked items, the list is empty.
I want to avoid doing the postback on every click which makes the screen flicker for a moment.
 
Please point me in the right direction.
 
Thanks,
Jim K
QuestionUpdate grid?sussAnonymous18 May '05 - 21:07 
how could I refresh the CI3Grid?

GeneralAdd Node After LoadmemberKhaled Ezz El Arab11 May '05 - 7:53 
How Can i Add New Node In Tree During Save A New Items After Tree Is Loaded
GeneralUpdatememberRobert19747 Feb '05 - 20:32 
I use a frameset and need to update the tree wrom within another frame. How can I do that. The best would be if I didnt have to use an update button.
Thanks in advance.
QuestionHi -- Is this the bug??memberxyz1120 Jan '05 - 5:29 
Hi -- I downloaded the demo project and trying it out. On the demo, when I click "product" the grid header says "[product]" ... Then I clicked "Computer Bags", the grid header says "Computer Bags" ... when I clicked "StileX Case", the grid hader says "StileX Case" .... but when I click "Computer Bags" again, the tree header still said "StileX Case" -- do I have to do something else to get this work. Thanks --
AnswerRe: Hi -- Is this the bug??memberbig7120 Jan '05 - 10:20 
Hi,
 
in the 0.23 version this should work just fine. You can download it from http://www.intre.it/osp[^].
 
big
 

GeneralRe: Hi -- Is this the bug??memberAlex Fil4 Jun '05 - 23:22 
Not fixed Frown | :-( (
GeneralKeep place for long treesmemberR2B217 Jan '05 - 4:56 
Great control! I ahve been looking for something like this for a while.
 
I am try to put a large organizational structure into your tree. When the user opens up a large tree such that they have to scroll down to see the node and then open it the sreen is defaulted back to the top of the screen.
 
Has anyone figured out how to make the screen scroll down to where the node was clicked?
 
Thanks,
Richard Binnington
GeneralRe: Keep place for long treesmemberMarco bij de Vaate20 Jan '05 - 22:05 
Hi,
 
I had the same problem and I solved this by adding an property to the CI3Node class like this:
 
Public Property ScrollTo() As Boolean
Get
Return m_scrollTo
End Get
Set(ByVal Value As Boolean)
m_scrollTo = Value
End Set
End Property

 
Than on the Page I add the event handlers:
OnNodeExpand
OnNodeCollapse
OnSelectChange

 
These handlers than call a method SetScrollTo that sets the Boolean
 
Public sub SetScrollTo(byval TreeObject as CI3Tree)
Dim TreeNode As CI3Node = TreeObject.FindNode(sKey)
Dim oldScrollToNode As CI3Node
oldScrollToNode = TreeObject.FindNode(TreeObject.ScrollToKey)
If Not oldScrollToNode Is Nothing Then
oldScrollToNode.ScrollTo = False
End If
TreeNode.ScrollTo = True
TreeObject.ScrollToKey = TreeNode.Key
End sub

 
Than added some code to the get GetTreeHtml method
 
Friend Overridable Function GetTreeHtml(ByRef req As HttpRequest) As String
Dim i As Int32
Dim sHtml As String
Dim nod As CI3Node
For i = 0 To m_nodChildren.Count - 1
nod = m_nodChildren(i)
sHtml = sHtml + nod.GetTreeHtml(req)
Next i
If Me.ScrollTo Then
sHtml = sHtml + CHtml.scrollTo
End If
 
Return sHtml
End Function

 
And to the CHtml object i added this method
 
Public Shared Function scrollTo() As String
Return "
"
End Function

 
Finally on the page i use the control i add a JavaScript to scroll to the div, this script looks like this:
 
function scrollIntoView()
{
if((document.getElementById("ScrollToThisNode") != null))
{
var ScrollNode = document.getElementById("ScrollToThisNode")
ScrollNode.scrollIntoView(false);
}
}

 
This script i run on my page onload and onresize events:
 
<body id=inbody onload="initPanel();" önresize="initPanel();">
This makes the page scroll to the div. the div will be show at the bottom of the region you scroll in
 
This was my solution to the problem. Hope it helped.
 

Grtz Marco

GeneralOnShowTreeFolders &amp; OnShowTreeItemsmemberMarco bdv17 Jan '05 - 0:08 
Hi,
 
First off all I want to say that the I3HTree control is a terrific control and that you did a wonderful job by creating it, but I have one question about it.
 
I want to have access to the children of a folder but when I use the option "eLoadWhenExpand" I can only access the children after the render method, witch is kind of late if you ask me, why didn't you build the control so that after the OnNodeExpand event is fired the "OnShowTreeFolders" & "OnShowTreeItems", so that the children can be accessed before the render method and not after
 
kind regards bdv

GeneralRe: OnShowTreeFolders &amp; OnShowTreeItemsmemberbig7120 Jan '05 - 10:15 
Hi,
 
I put all the control logic in the ovveride of the Render method of the control so what you are saying is true.
 
The control Render code is:
 
Protected Overrides Sub Render(…)
InitTree()
output.Write(m_tree.GetHtml(Page.Request()))
End Sub
 
A possible solution is defining a new event and firing it before the Render:
 
Protected Overrides Sub Render(…)
InitTree()
Dim sHtml As String = m_tree.GetHtml(Page.Request())
 
RaiseEvent (NEW EVENT )

output.Write(sHtml)
End Sub
 
In this case the NEW EVENT can be handled and it is fired before the end of the Render.
What do you think?
 
Bye,
big

GeneralRe: OnShowTreeFolders &amp; OnShowTreeItemsmemberMarco bij de Vaate20 Jan '05 - 21:38 
Hi,
 
You’re idea is a good one, but I would change raise the event before
 
Dim sHtml As String = m_tree.GetHtml(Page.Request())
So the code would look like this:
 
Protected Overrides Sub Render(…)
InitTree()
 
RaiseEvent (NEW EVENT )
 
Dim sHtml As String = m_tree.GetHtml(Page.Request())
 
output.Write(sHtml)
End Sub

 
The reason for this is that I want to change some of the properties of the children before the html output is created.
 
My own solution for the problem was to override the OnPreRender method. And call the InitTree method from there. So I could make changes in the PreRender event of the page,
 

Protected Overrides Sub OnPreRender(ByVal e As EventArgs)
InitTree()
 
MyBase.OnPreRender(e)
End Sub

 

But the solution you offer is a bit nicer, raise an event and than in the event handler of that event make the changes I want. I actually changed to code so it looks like this:
 
Protected Overrides Sub OnPreRender(ByVal e As EventArgs)
InitTree()
 
RaiseEvent (NEW EVENT )
 
MyBase.OnPreRender(e)
End Sub
 
Protected Overrides Sub Render(…)
Dim sHtml As String = m_tree.GetHtml(Page.Request())
 
output.Write(sHtml)
End Sub

 
In this way only the rendering is done in the render method and all other things that need to be done are done just before that
 
Thanx for remain
 
Thnx for reminding me about events
 
Grtz marco
 

Generaldrag and dropmemberadinbar13 Jan '05 - 3:28 
is there a method for drag and drop?
thx adi
 
gc will eat u alive
GeneralRe: drag and dropmemberbig7113 Jan '05 - 9:52 
no...so far...
big
GeneralDoes Not WorkmemberRuben Silva Fragoso17 Dec '04 - 12:28 
Hi i have just dowload the latest version of this control, and i doesn't work, the first sign, was the fact that it does allow me to drag the control from the toolbox to the page, i then tried to compile the project, again, but same error, i also remove the first version , that i had installed(that was workingfine), and still it does not work, i then tried to get the project with the first version, and tried to change the reference from I3HTreectrl, to just I3HTree just as you said in your page, but it does not recognizes the new version
GeneralBug in DeleteNode methodmemberK@meel7 Dec '04 - 21:44 
Hello,
 
There is a bug in the DeleteNode method from the CI3Tree class.
You end the function when te node to delete is something, instead of nothing.
 
Change the following in the CI3Tree class to solve the problem:
 
Public Function DeleteNode(ByRef nodToDelete As CI3Node) As Boolean
If Not nodToDelete Is Nothing Then
Return False
End If
 
To:
 
Public Function DeleteNode(ByRef nodToDelete As CI3Node) As Boolean
If nodToDelete Is Nothing Then
Return False
End If
 
Thanks for your great control!
 
Marco
 

GeneralRe: Bug in DeleteNode methodmemberbig718 Dec '04 - 6:26 
OK, thank you!
 
big
GeneraldataGrid contains old valuesmemberAshima atul17 Nov '04 - 20:44 
The page containing the tree control is being called by different pages to show the tree view of different functinalities.The problem i am facing is that once the tree view and datagrid is populated for a particular functionality, if i come back to this page again for another functionality the old values still remain.The event fired OnAddFolders and OnShowDataGridItems get the sParentKey with reference to the old data.
GeneralRe: dataGrid contains old valuessussSiddharth Taneja16 Sep '05 - 11:42 
Very nice.
AnswerRe: How 'paging' datagrid result ??memberbig7116 Nov '04 - 6:24 
The paging feature is not implemented yet... and even if I think is very interesting I cannot say when I will add it.
 
If you want you could try to modify the control. As suggestion I would say:
 
Replace the OnShowGridItems event with 2 new events
 
OnShowGridInfo(ByVal sParentKey As String, _
ByRef sGridTypeId As String, _
ByRef sGridCaption As String, _
ByRef bUsePages As Boolean, _
ByRef nNoOfPages As Int32)
 
Here it is possible to specify the grid information given the selected parent.
 
The OnShowGridItems event shall be modified as follows:
 
OnShowGridItems (ByVal sParentKey As String, _
ByVal nPageNo As Int32, _
ByRef aKey As System.Collections.ArrayList)
 
Here the control provides the page number and the application shall fill the aKey array with the data in the page.
 

Bye,
big
QuestionHow 'paging' datagrid result ??memberlucas197614 Nov '04 - 23:53 
How 'paging' datagrid result, when number o records is to large ??
GeneralCollapse allmembergadgetguru13 Sep '04 - 4:02 
Probably a lame question, but how can I collapse all (so basically from the ROOT) after a submit ?
 
(thanks btw for the fast fixes and the implementation regarding my submit request!)
 
TIA
GeneralRe: Collapse allmemberbig7113 Sep '04 - 22:59 
just do the following:
Dim fldRoot As I3HTreeCtrl.CI3Folder
fldRoot = i3htree.GetTreeObject().FindNode("ROOT")
fldRoot.CollapseNode()
CollaspeAll(fldRoot)
 
where the CollapseAll sub is:
 
Private Sub CollaspeAll(ByRef nodParent As I3HTreeCtrl.CI3Node)
 
Dim nod As I3HTreeCtrl.CI3Node
 
For Each nod In nodParent.m_nodChildren
 
If nod.GetNodeType() = I3HTreeCtrl.CI3Tree.enumNodeType.eFolder Then
Dim fld As I3HTreeCtrl.CI3Folder = nod
fld.CollapseNode()
 
CollaspeAll(fld)
End If
Next
 
End Sub
 
big
GeneralComboBoxmemberlucas197613 Sep '04 - 1:09 
How can I fill comboBox directly from database ??
GeneralRe: ComboBoxmemberbig7113 Sep '04 - 22:45 
Hi,
 
so far there is no ‘bound’ support in the I3HTree control.
The only way to add combo items is using the methods of the CI3ColHeader class.
 
Dim col As I3HTreeCtrl.CI3ColHeader

col.ClearComboItems()
col.AddComboItem(1, "item1")
col.AddComboItem(2, "item2")
 
big
Generalcan't get GetCheckedItemList() to workmembergadgetguru6 Sep '04 - 4:37 
I'm trying to get all the checked values with :
 
..//
Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim aChecked As System.Collections.ArrayList
i3htree.GetTreeObject().GetCheckedItemList(aChecked)
//..
 
but my ArrayList (aChecked) stays empty !
I'm going nuts trying to find out why this isn't working..

GeneralRe: can't get GetCheckedItemList() to workmemberbig716 Sep '04 - 6:52 
I think that the problem is that the list is loaded when the page is submitted. Check some items and then force a submit (for instance changing the node selection) and then click on the Button1. You will see that the list is not empty.
 
To solve the problem you have to force a page submit before the Button_Click event.
 
On the other hand I could implement the submit on the OnChange event as I did for the grid item checkbox cell.
I think I will add this in the next release.
 
bye,
big
GeneralRe: can't get GetCheckedItemList() to workmembergadgetguru6 Sep '04 - 9:43 
Hi,
Yes, you're right..when forcing a page submit before the button_click the list is filled. (this is a bit unfortunate)
thanks for the tip !
 

GeneralRe: can't get GetCheckedItemList() to workmembergadgetguru6 Sep '04 - 22:53 
I can't create an acceptable workaround for forcing the paging before the button is clicked.
This is a real bummer since this control was exactly what I was looking for. Basically I'm planning (has planned) to use this one as a front-end for a search engine - using the checkboxes to check the category one wants to search.
However, like stated before, when simply checking some checkboxes the list of results isn't populated... When unfolding another branch first, which performs a submit, does fill the results. However, this is ofcourse not an acceptable workaround.
I can't seem to find a way to force this (without any special user input) - If somebody has an idea, I 'd highly appreciate it .. Otherwise I 'll have to start looking again for another control .. (or re-invent the wheel again)
 
TIA,
 

 

GeneralRe: can't get GetCheckedItemList() to workmemberbig716 Sep '04 - 23:25 
I already implemented it in the grid items; the postback event on the control is automatically triggered any time the control value is changed (textbox, combobox, checkbox).
 
I could do the same for tree checkbox items and this shall solve your problem.
I think I could have a new release in few days.
 
big
GeneralRe: can't get GetCheckedItemList() to workmemberbig719 Sep '04 - 5:15 
Hi,
 
I have just released the 0.23 version on http://www.intre.it/osp/i3htree.htm[^]. This should solve your problem.
 
Just make sure you set the eSaveOnChange style on the Page_Load:
 
i3htree.I3HSaveStyle = I3HTreeCtrl.CI3Tree.enumSaveStyle.eSaveOnChange
 
This will casuse an automatic postback every time the user check/uncheck a tree item.
 
big
GeneralRe: can't get GetCheckedItemList() to workmembergadgetguru9 Sep '04 - 21:35 
thanks!
Generalpicture obligatory with TreeCheckboxmembergadgetguru5 Sep '04 - 23:33 
Cool control, but I can't seem to prevent the use of a picture next to my checkbox. Is this normal ?
GeneralRe: picture obligatory with TreeCheckboxmemberbig716 Sep '04 - 6:44 
this is a bug! I will fix in the next release. The problem is in the CI3ItemTree::GetTreeHtml method.
 
But first of all you have to set the default item image with a null string in the Page_Load method:
 
i3htree.I3HItemDefaultImage = ""
 
Then to fix the bug replace the following code in the CI3ItemTree::GetTreeHtml method
 
sHtmlImg = CHtml.Cell(, "2%", , CHtml.HALIGN.HALIGN_CENTER, CHtml.VALIGN.VALIGN_MIDDLE) + _
sSpace + _
CHtml.CheckBox(sCheckBoxId, m_bChecked) + _
CHtml._Cell + _
CHtml.Cell(, "2%", , CHtml.HALIGN.HALIGN_CENTER, CHtml.VALIGN.VALIGN_MIDDLE) + _
CHtml.Link(m_sHRef, "", m_sTarget) + _
CHtml.Image(m_sImage) + _
CHtml._Link + _
CHtml._Cell
 
with
 
Dim sItemImage As String = ""
If m_sImage <> "" Then
sItemImage = CHtml.Image(m_sImage)
End If
sHtmlImg = CHtml.Cell(, "2%", , CHtml.HALIGN.HALIGN_CENTER, CHtml.VALIGN.VALIGN_MIDDLE) + _
sSpace + _
CHtml.CheckBox(sCheckBoxId, m_bChecked) + _
CHtml._Cell + _
CHtml.Cell(, "2%", , CHtml.HALIGN.HALIGN_CENTER, CHtml.VALIGN.VALIGN_MIDDLE) + _
CHtml.Link(m_sHRef, "", m_sTarget) + _
sItemImage + _
CHtml._Link + _
CHtml._Cell
 
bye,
big
GeneralRe: picture obligatory with TreeCheckboxmembergadgetguru6 Sep '04 - 9:20 
thx, I 'll try that !
Generalc# projectmembermichal.hruby2 Aug '04 - 0:15 
I tried new version web control I3Htree in C# project and I met with the same porblem like in previous version.
Compilation error Message: CS0234: The type or namespace name 'I3HTreeCtrl' does not exist in the class or namespace 'I3HTreeCtrl.I3HTreeCtrl' (are you missing an assembly reference?).
In VB.Net project this web control works right.
Can you help me?

GeneralRe: c# projectmemberbig7124 Aug '04 - 1:15 
I just post the latest (0.22) version that fixes the C# problem.
For solving it I had to change the name of the control from I3HTreeCtrl.I3HTreeCtrl to I3HTreeCtrl.I3HTree...
don't ask me way...
 
Let me know if now works!
 
big
GeneralFolder functionalitymemberPieta S28 Jul '04 - 22:14 
Thank you for a stunning control.
 
A possible functionality change: What I propose is for the folders to have similar functionality to the items. Folders could also have href and target attributes. This would enable folders to link to outside pages / what- or whereever.
 
I do understand that the folders already contain functionality for load-on-demand as well as expanding which would make adding more functionality difficult.
GeneralRe: Folder functionalitymemberbig7129 Jul '04 - 6:29 
I thought that folders have another scope but I agree that there is no reason for having this limitation.
 
I think that what you suggest can be done...I will try to add it in the next release of the control.
 
Bye,
big

GeneralConventions...memberlabreuer23 Jul '04 - 3:38 
The below is obviously opinion, so don't take any of it personally. I am telling you the below because I think it will a) make your life easier in the long run and b) make it easier for others to understand your code. I believe that the more standards are adhered to, the easier life is in the end.
 
You should probably take a look at some of Microsoft's naming conventions. For example, you name your events OnSomething -- that could be very confusing to people, when they're used to OnXXX being a protected function that they can override to do what they want. Typically you have an event XXX, and it's handled in your custom control with the function OnXXX.
 
Make use of namespaces: make the namespace of your control something like "I3H" and name your control "TreeView" or something like that.
 
Microsoft also suggests NOT prefixing classes with "C" as classes are more central to .NET than in VB -- the "C" prefix will simply get old.
 
Prefixing enumerations with "enum" and the elements with "e" is also unnecessary. Unlike VB6, you'll reference enumerated values as Enumeration.Element, which makes things a lot clearer and makes prefixes much less important. In addition, your enumerated types should have names that make it decently obvious that they are enumerated types.
 
Make greater use of the Imports statement, to reduce having to type "Collections.ArrayList" and such.
 
Comment more!

GeneralRe: Conventions...memberbig7126 Jul '04 - 20:55 
I agree with you that standards are important...the problem is that sometimes Microsoft play too much in changing it.
 
For instance some years ago Microsoft was pushing for Hungarian notation while now it is saying that Camel notation is the best choice (actually I don’t like Camel notation at all…). The problem is that when you work in big projects, that last years, it is not feasible changing the code style guide in the middle.
 
Probably it will take a while…
 
Thanks for your comments,
 
Regards,
big

Generalerrormemberteddybear19 Jul '04 - 6:45 
When I tried to browse MyOrderForm.aspx, the following error occured:
 
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
 
Parser Error Message: Could not load type 'I3TreeDemo2.Global'.
 
Source File: C:\download\demo\MyOrderForm\global.asax      Line: 1

 
I look like a bear and move very slowly. But I hope to please you.
GeneralRe: errormemberbig7119 Jul '04 - 7:48 
sorry for that!
 
Open global.asax with notepad and replace I3TreeDemo2 with MyOrderForm.
 
I3TreeDemo2 was the old name of the project but I did not get the error you see untill I delete all my bin and obj stuff and I rebuild all.
 
big
QuestionNeat. But...?memberpcmehta_hcl7 Jul '04 - 7:55 
This is very neat and handy program, but why do you use such obscure names like "I3" inconsistenly throughout the namespaces.
 
Codewise this is usable.
 
thx for great contribution.
 
<>
GeneralSetting the checkbox true on creationmemberSidney1234567896 Dec '04 - 6:01 
Hi Big71,
 
This is a fantastic control, but it would be even better if you could explain how to check the checkbox when creating it in the 'i3htree_OnShowTreeItems' event.
 
I have tried the following within the 'i3htree_OnShowTreeItems' event:
 
sGrid = Convert.ToString(dr("grid"))
aKey.Add(sGrid)
aCaption.Add(dr("site"))
Dim itm As I3HTreeCtrl.CI3Tree
itm = I3HTree.GetTreeObject()
itm.CheckItem(sGrid, True)
 
It does not work. However if I place the following code on a button it works:
Dim itm As I3HTreeCtrl.CI3Tree
itm = I3HTree.GetTreeObject()
itm.CheckItem(sGrid, True)
 
However I cannot find an event handler that can check the item after loading.Confused | :confused:
 
How can I do this?
 
Kind Regards,
 

 

 

 
Sidney123456789
GeneralRe: Setting the checkbox true on creationmemberbig718 Dec '04 - 6:24 
Hi and thanks!
 
Your code cannot work because when you call the itm.CheckItem(sGrid, True) the item sGrid does not exist yet (you are still inside the OnShowTreeItems event).
 
This is definitely a missing functionality of the control since the checked/unchecked state shall be a parameter of the OnShowTreeItems event. I will do it in the next release.
 
In the mean time a possible workaround is the following. In the OnShowTreeItems instead of filling the arrays just create the item directly:
 
Private Sub i3htree_OnShowTreeItems(ByVal sParentKey As String, _
ByRef aKey As System.Collections.ArrayList, _
ByRef aCaption As System.Collections.ArrayList, _
ByRef aImage As System.Collections.ArrayList, _
ByRef aLink As System.Collections.ArrayList, _
ByRef aTarget As System.Collections.ArrayList, _
ByRef aTDClass As System.Collections.ArrayList, _
ByRef aAClass As System.Collections.ArrayList, _
ByRef aASelectedClass As System.Collections.ArrayList) Handles i3htree.OnShowTreeItems
 
If sParentKey = "MyKey" Then
 
Dim itm As New I3HTreeCtrl.CI3ItemTree(i3htree.GetTreeObject(), _
i3htree.GetTreeObject().FindNode(sParentKey), _
"MyItemKey", _
"MyItemCaption", _
"", _
"", _
"", _
"", _
"", _
"")
itm.CheckNode(True)
 
End If
End Sub
 
Hope this help!
 
Bye,
big

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 24 Aug 2004
Article Copyright 2004 by big71
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid