Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Question about DotNetJunkies Hierarchical dg example

Reply
Thread Tools

Question about DotNetJunkies Hierarchical dg example

 
 
PedalChick
Guest
Posts: n/a
 
      08-07-2003
I've been trying to customize this code
http://www.dotnetjunkies.com/Tutoria...3&forumID=4117
to suit my own needs. I can get the hierarchical display using this
method - it's pretty cool! But I have one problem that screws up the
entire +/- show/hide concept.
Here's the deal - I am getting my data from an Access db rather that
SQL used in their example.
When trying to track down why exactly nothing regarding the +/-
functions worked, I discovered this strangeness: although the empty
cells (left in the detail rows, right in the master rows) appear empty
on the screen, and if you try and highlight them you get a single
space highlighted, all of the If statements that depend on the text =
" " (eg. dgValues.Items(icount).Cells(1).Text = " ") never work.

Is there another way to create this If statement? I tried using
Len(dgValues.Items(iCount).Cells(1).Text) < 1, = 1, > 1 - this never
worked because for some reason, the length of the string in the empty
cells was always 6 is the cell was empty.
WTF?
If the cell contains data, the len() calculation is correct.

Please help!!!
What is in that cell that I cannot see?
 
Reply With Quote
 
 
 
 
Justin Dutoit
Guest
Posts: n/a
 
      08-09-2003
It could be &nbsp; Downlevel browsers like Netscape 4 (@$**!!) won't
render the table cell unless there is an &nbsp; in it (non-breaking space).

hth
Justin Dutoit



"PedalChick" <> wrote in message
news: m...
> I've been trying to customize this code
>

http://www.dotnetjunkies.com/Tutoria...22C9-FFBD-4C57
-BD48-F62B55057FF3&forumID=4117
> to suit my own needs. I can get the hierarchical display using this
> method - it's pretty cool! But I have one problem that screws up the
> entire +/- show/hide concept.
> Here's the deal - I am getting my data from an Access db rather that
> SQL used in their example.
> When trying to track down why exactly nothing regarding the +/-
> functions worked, I discovered this strangeness: although the empty
> cells (left in the detail rows, right in the master rows) appear empty
> on the screen, and if you try and highlight them you get a single
> space highlighted, all of the If statements that depend on the text =
> " " (eg. dgValues.Items(icount).Cells(1).Text = " ") never work.
>
> Is there another way to create this If statement? I tried using
> Len(dgValues.Items(iCount).Cells(1).Text) < 1, = 1, > 1 - this never
> worked because for some reason, the length of the string in the empty
> cells was always 6 is the cell was empty.
> WTF?
> If the cell contains data, the len() calculation is correct.
>
> Please help!!!
> What is in that cell that I cannot see?



 
Reply With Quote
 
 
 
 
PedalChick
Guest
Posts: n/a
 
      08-15-2003
"Justin Dutoit" <> wrote in message news:<eqPd#>...
> It could be &nbsp; Downlevel browsers like Netscape 4 (@$**!!) won't
> render the table cell unless there is an &nbsp; in it (non-breaking space).
>
> hth
> Justin Dutoit
>

Thanks! That little note helped get me over my stumbling block and
I've since gotten this cool little widget not only to work correctly,
but have made some improvements. I've added an "expand all" to the
two detail levels and a "collapse all" once they have been expanded.

It turns out the " " vs. "&nbsp;" issue was due to Dreamweaver MX
changing the latter to the former and screwing me up every time I
changed. I have to hand edit in Notepad now...

The grid has three levels, the two expand/collapse buttons are in
cells 0 and 3.
I'll leave out the html...
Imports System
Imports System.Web.UI
Imports System.Web.UI.Webcontrols
Imports System.Data
Imports System.Data.OleDb
Imports System.Data.OracleClient
Public Class NestedTest
Inherits System.Web.UI.Page
Protected WithEvents MyDataGrid As
System.Web.UI.WebControls.DataGrid
Protected WithEvents lblResults As System.Web.UI.WebControls.Label
Protected WithEvents ddlSubmitters as
System.Web.UI.WebControls.Dropdownlist
Protected WithEvents outError As
System.Web.UI.HtmlControls.HtmlGenericControl
Protected WithEvents expBinary as
System.Web.UI.WebControls.LinkButton
Protected WithEvents expQuery as System.Web.UI.WebControls.LinkButton
#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form
Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub PageLoad(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack then
<snip> I start out with a dropdownlist to select data based upon the
submitter and then load the data.</snip>
End If
End Sub

Public Sub ChangeSelectedList(ByVal sender As Object, ByVal objArgs As
System.EventArgs) Handles ddlSubmitters.SelectedIndexChanged
LoadData()
End Sub


Private Sub LoadData()
<snip> fill a dataset with tables and establish relationships. Write
out the data into a new table using the dotnetjunkies example and bind
the table to the datagrid</snip>
MyDataGrid.DataSource = objTable
MyDataGrid.DataBind()
expQuery.visible = true
expBinary.visible = false
SetHierarchical(0)
End Sub

Private Sub SetHierarchical(ByVal bExpanded As Integer)
Dim iCount As Int32
lblResults.Text = MyDataGrid.Items.Count
If bExpanded = 1 Then
For iCount = 0 To MyDataGrid.Items.Count - 1

If MyDataGrid.Items(iCount).Cells(1).Text <> "&nbsp;" Then
CType(MyDataGrid.Items(iCount).Cells(0).Controls(0 ),
LinkButton).Text = "-"
End If
Next
For iCount = 0 to MyDataGrid.Items.Count - 1

Do While MyDataGrid.Items(iCount).Cells(1).Text =
"&nbsp;"
If MyDataGrid.Items(iCount).Cells(4).Text <>
"&nbsp;" Then MyDataGrid.Items(iCount).Visible = True
iCount += 1
If iCount >= MyDataGrid.Items.Count Then Exit
Do
Loop
expQuery.Text = "Collapse Queries"


Next

Else if bExpanded = 0 Then
For iCount = 0 To MyDataGrid.Items.Count - 1
'hide + on all rows where there is not an
expandable node
If MyDataGrid.Items(iCount).Cells(4).Text =
"&nbsp;" Then

MyDataGrid.Items(iCount).Cells(3).Controls(0).Visi ble = False
Else
'set the plus sign

CType(MyDataGrid.Items(iCount).Cells(3).Controls(0 ), LinkButton).Text
= "+"

CType(MyDataGrid.Items(iCount).Cells(3).Controls(0 ),
LinkButton).CssClass = "secondaryNav"
End If
'hide + on all Query rows where there is not an
expandable node
If MyDataGrid.Items(iCount).Cells(1).Text =
"&nbsp;" Then

MyDataGrid.Items(iCount).Cells(0).Controls(0).Visi ble = false
Else
'set the plus sign

CType(MyDataGrid.Items(iCount).Cells(0).Controls(0 ), LinkButton).Text
= "+"

CType(MyDataGrid.Items(iCount).Cells(0).Controls(0 ),
LinkButton).CssClass = "secondaryNav"
End If

'hide all child nodes and rows of the root nodes
If MyDataGrid.Items(iCount).Cells(1).Text =
"&nbsp;" Then
MyDataGrid.Items(iCount).Visible = False
End If
expQuery.Text = "Expand Queries"
Next
End If
bExpanded = 0
End Sub

Private Sub MyDataGridItemCommand(ByVal source As Object, ByVal e
As System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
MyDataGrid.ItemCommand
Dim iCount As Int32 = e.Item.ItemIndex + 1
If e.CommandName = "ExpandBinary" Then
If CType(e.Item.Cells(3).Controls(0), LinkButton).Text
= "-" Then
'Hide all child rows in the node careful not to
hide the Query row
Do While MyDataGrid.Items(iCount).Cells(4).Text =
"&nbsp;" And MyDataGrid.Items(iCount).Cells(1).Text = "&nbsp;"
MyDataGrid.Items(iCount).Visible = False
iCount += 1
If iCount >= MyDataGrid.Items.Count Then Exit
Do
Loop
'change the minus to a plus
CType(e.Item.Cells(3).Controls(0),
LinkButton).Text = "+"
Else
'Show all child rows in the node
Do While MyDataGrid.Items(iCount).Cells(4).Text =
"&nbsp;"
MyDataGrid.Items(iCount).Visible = True
iCount += 1
If iCount >= MyDataGrid.Items.Count Then Exit
Do
Loop
'change the plus to a minus
CType(e.Item.Cells(3).Controls(0),
LinkButton).Text = "-"
End If
ElseIf e.CommandName = "ExpandQuery" Then
If CType(e.Item.Cells(0).Controls(0), LinkButton).Text
= "-" and iCount < MyDataGrid.Items.Count Then
'Hide all child rows in the node
Do While MyDataGrid.Items(iCount).Cells(1).Text =
"&nbsp;"
MyDataGrid.Items(iCount).Visible = False
'if this is a binary row set the plus sign as
we are collapsing it too
If MyDataGrid.Items(iCount).Cells(4).Text <>
"&nbsp;" Then CType(MyDataGrid.Items(iCount).Cells(3).Controls(0 ),
LinkButton).Text = "+"
iCount += 1
If iCount >= MyDataGrid.Items.Count Then Exit
Do
Loop
'hide the total row

'change the minus to a plus
CType(e.Item.Cells(0).Controls(0),
LinkButton).Text = "+"
Else
'Show all Binary rows in the node
If iCount < MyDataGrid.Items.Count Then
Do While MyDataGrid.Items(iCount).Cells(1).Text =
"&nbsp;"
If MyDataGrid.Items(iCount).Cells(4).Text <>
"&nbsp;" Then MyDataGrid.Items(iCount).Visible = True
iCount += 1
If iCount >= MyDataGrid.Items.Count Then Exit
Do
Loop
'change the plus to a minus
CType(e.Item.Cells(0).Controls(0),
LinkButton).Text = "-"
Else if iCount = MyDatagrid.Items.Count Then
If MyDataGrid.Items(iCount).Cells(1).Text = "&nbsp;" and
MyDataGrid.Items(iCount).Cells(4).Text <> "&nbsp;" Then
MyDataGrid.Items(iCount).Visible = True
Else
MyDataGrid.Items(iCount).Visible = False
End If
CType(e.Item.Cells(0).Controls(0), LinkButton).Text = "-"
End If
End If

End Sub

Private Sub ChangeAllQuery(Sender As System.Object, ByVal objArgs As
System.EventArgs) Handles ExpQuery.Click
If expQuery.Text = "Expand Queries" Then
expBinary.visible = true
expBinary.Text = "Expand Binaries"
SetHierarchical(1)
Else
expBinary.visible = false
SetHierarchical(0)
End If

End Sub
Private Sub ChangeAllBinary(Sender As System.Object, ByVal e As
System.EventArgs) Handles ExpBinary.Click
If expBinary.Text = "Expand Binaries"
Dim iCount As Int32

For iCount = 0 To MyDataGrid.Items.Count - 1
'Show all child rows in the node
If CType(MyDataGrid.Items(iCount).Cells(3).Controls(0 ),
LinkButton).Text = "+"
CType(MyDataGrid.Items(iCount).Cells(3).Controls(0 ),
LinkButton).Text = "-"
End If
Next
For iCount = 0 To MyDataGrid.Items.Count - 1
Do While MyDataGrid.Items(iCount).Cells(4).Text =
"&nbsp;"
MyDataGrid.Items(iCount).Visible = True
iCount += 1
If iCount >= MyDataGrid.Items.Count Then Exit
Do
Loop

Next
expBinary.Text = "Collapse Binaries"

Else
Dim iCount As Int32

For iCount = 0 To MyDataGrid.Items.Count - 1
If CType(MyDataGrid.Items(iCount).Cells(3).Controls(0 ),
LinkButton).Text = "-"
CType(MyDataGrid.Items(iCount).Cells(3).Controls(0 ),
LinkButton).Text = "+"
End If
Next
For iCount = 0 To MyDataGrid.Items.Count - 1
Do While MyDataGrid.Items(iCount).Cells(4).Text = "&nbsp;" And
MyDataGrid.Items(iCount).Cells(1).Text = "&nbsp;"
MyDataGrid.Items(iCount).Visible = False
iCount += 1
If iCount >= MyDataGrid.Items.Count Then Exit
Do
Loop
'change the minus to a plus

Next
expBinary.Text = "Expand Binaries"
End If

End Sub
End Class
 
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
Hierarchical Datagrid Question james ASP .Net Datagrid Control 0 03-25-2005 01:24 PM
'example.com' == 'example.com.' => false... is this intended? Sam Roberts Ruby 15 02-07-2005 04:36 PM
Converting 'flat' gate level names to hierarchical names Paddy McCarthy VHDL 3 09-24-2004 05:34 PM
Hierarchical Credit-based Queuing (HCQ): QoS implementation feedback? Vicky Cisco 0 05-09-2004 07:07 AM
hierarchical design with structural VHDL question Neil Zanella VHDL 2 10-22-2003 11:01 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57