Most Suitable control suggestion

4 posts, 0 answers
  1. Kieran Southern
    Kieran Southern avatar
    116 posts
    Member since:
    Oct 2004

    Posted 14 Jun 2006 Link to this post

    Hi,

    Can anyone suggest a suitable control from the controls suite for achieving the data layout like so:

    http://perryworld.co.uk/testarea/sample.gif

    It is basically a parent, with a count of children and then each child with a count of their children. I was considering the repeater control but thought there may be a telerik control that is suitable.

    Many Thanks
    Kieran
  2. Shaun Peet
    Shaun Peet avatar
    571 posts
    Member since:
    Aug 2004

    Posted 14 Jun 2006 Link to this post

    If you're looking for something to repeat horizontally like in the picture, then a repeater is probably your best option.  I'm thinking a TreeView would be ideal if you could go vertically (or a Panelbar).

    Having said all that, it depends on what you are trying to accomplish.  Are you looking for any kind of interactivity with this list?  For example, do you want to hide the children until the parents are "expanded"?  We often lose sight of the fact that telerik designs user interface controls.  And they do a great job of it.  However, when all you want to do is simply display data without user interaction; that doesn't necessarily require a user interface.  In fact, you will probably find that you will save an awful lot of bandwidth by using controls, such as the repeater, that are specifically designed to not be interactive by defualt.  It's the classic "datagrid" vs. "repeater" argument - both can output the exact same design; but the datagrid was designed to be interactive and carries with that a heavy footprint.
  3. Kieran Southern
    Kieran Southern avatar
    116 posts
    Member since:
    Oct 2004

    Posted 15 Jun 2006 Link to this post

    Hi,

    Thanks for this. No, I dont need expand/collapse, I have a self referencing table like:

    id    name       parentid
    1     Cyprus     -1
    2     Paphos    1
    3     Limassol  1
    4     USA        -1
    5     Florida     4
    6     New York 4

    And I need to achieve the following layout:

    Cyprus (2)          USA (2)
      Limassol (5)       New York(18)
      Paphos (8)         Florida (22)

    (The Child items under Limassol, Paphos etc are in a seperate 'properties' table.)

    in a 3 by however many rows are required. I've been looking also at the datalist as that will allow me to display the 3 across, though getting the data from the sql db in the correct format is proving tricky.

    Any suggestions greatly appreciated.

    Thanks
    Kieran
  4. Shaun Peet
    Shaun Peet avatar
    571 posts
    Member since:
    Aug 2004

    Posted 18 Jun 2006 Link to this post

    If you want to do it manually; here you go:

        Private Function CreateTable() As HtmlTable
            Dim outputTable As New HtmlTable
            Dim cols As Integer = 3
            Dim dtParents As New Data.DataTable ' SQL Select = "SELECT * FROM TABLE WHERE parentID = -1"
            Dim numParents As Integer = dtParents.Rows.Count
            Dim fullrows As Integer = Math.Floor(numParents / cols)
            Dim leftovers As Integer = numParents - (fullrows * cols)
            Dim intR As Integer = 1 ' Counts the number of rows for the loop
            Dim currentParentRow As Integer = 0 ' Sets the current index in the datatable
            Do While intR < fullrows
                intR += 1
                Dim outputTableRow As New HtmlTableRow
                Dim intC As Integer = 1 ' Counts the number of columns for the loop
                Do While intC < cols
                    intC += 1
                    Dim outputTableCell As New HtmlTableCell
                    ' Get the row from the dtParents datatable correstponding to the current cell
                    Dim rParent As Data.DataRow = dtParents.Rows(currentParentRow)
                    currentParentRow += 1
                    outputTableCell.InnerHtml = rParent("Name") & "<br />"
                    Dim dtChildren As New Data.DataTable ' SQL Select = "SELECT * FROM TABLE WHERE parentID = r("ID")"
                    ' Get your additional info for each child from your other table
                    Dim additionalInfo As String = "(" & "other properties" & ")"
                    For Each rChild As Data.DataRow In dtChildren.Rows
                        outputTableCell.InnerHtml += "&nbsp;&nbsp;" & rChild("Name") & " " & additionalInfo & "<br />"
                    Next
                    outputTableRow.Cells.Add(outputTableCell)
                Loop
                outputTable.Rows.Add(outputTableRow)
            Loop
            If leftovers > 0 Then
                Dim outputTableRow As New HtmlTableRow
                Do While leftovers < cols
                    leftovers += 1
                    Dim outputTableCell As New HtmlTableCell
                    ' Get the row from the dtParents datatable correstponding to the current cell
                    Dim rParent As Data.DataRow = dtParents.Rows(currentParentRow)
                    currentParentRow += 1
                    outputTableCell.InnerHtml = rParent("Name") & "<br />"
                    Dim dtChildren As New Data.DataTable ' SQL Select = "SELECT * FROM TABLE WHERE parentID = r("ID")"
                    ' Get your additional info for each child from your other table
                    Dim additionalInfo As String = "(" & "other properties" & ")"
                    For Each rChild As Data.DataRow In dtChildren.Rows
                        outputTableCell.InnerHtml += "&nbsp;&nbsp;" & rChild("Name") & " " & additionalInfo & "<br />"
                    Next
                    outputTableRow.Cells.Add(outputTableCell)
                Loop
            End If
            Return outputTable
        End Function

    Copy and paste that entire function into your vb and it should make a little more sense.

    Sometimes when the "black boxes" of the world won't let me do exatly what I want, I do it myself and it often makes more sense that way.
Back to Top