We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Tree view - Load on demand from sql datasource

Hi

Does anyone have an example of how you would load on demand a child node using a datasource?

Thanks in advance

Ross


7 Replies

VR Varalakshmi R.S Syncfusion Team May 4, 2012 06:19 AM UTC

Hi Ross,

Thanks for contacting Syncfusion forums.

You may refer the following online sample which clearly exhibits the behavior of LoadOnDemand in TreeView control,
ASP.NET MVC: http://mvc.syncfusion.com/sfmvcsamplebrowser/10.1.0.44/Tools_MVC/Samples/4.0/treeview/LoadOnDemand
ASP.NET: http://asp.syncfusion.com/demos/ui/tools/TreeView/LoadOnDemand/cs/LoadOnDemand.aspx

Regards,
Varalakshmi




RM Ross Macintyre May 10, 2012 04:20 PM UTC

    Thanks Varalakshmi, I have looked at the examples for ASP.net although the example shown is for a manually created node.

I am having trouble making the step between a databound tree and loading the child on demand

I could be completely going down the wrong path, although an example of what I am trying to do, which is take some of your example is below.

ANY help would be greatly appreciated.

Protected Sub TreeView1_NodeExpanded(sender As Object, e As Syncfusion.Web.UI.WebControls.Tools.TreeViewNodeEventArgs) Handles TreeView1.NodeExpanded

        e.Node.Items.Add(Me.BuildTree(e.Node.ID))

    End Sub

    Private Function BuildTree(nClientID As String) As TreeViewNode
        Dim dsGroup As New DataSet
 dsGroup = ReturnClientTree(sClient)

        Dim oTree As TreeView = New TreeView()
        oTree.DataSource = dsGroup
        oTree.DataMember = dsGroup.Tables(0).TableName

        Dim oTv As New TreeViewItemBinding
        oTv.DataMember = dsGroup.Tables(0).TableName
        oTv.ParentIDField = "PID"
        oTv.TextField = "MDESC"
        oTv.IDField = "MID"
        oTv.Expanded = True
        oTree.DataBindings.Add(oTv)
        oTree.DataBind()

        Return oTree.Items(0) 'ISSUE: this only returns the first node, but the theory works

    End Function



VR Varalakshmi R.S Syncfusion Team May 11, 2012 07:25 AM UTC

Hi Ross,

Thanks for the update.

TreeView node should be returned from the BuildTree event for this requirement and you have used “oTree.Items(0)” which always returns first node of the TreeView. Can you please share a simple sample with us to see the exact issue. It would help us on analyzing your needs.

Regards,

Varalakshmi



RM Ross Macintyre May 11, 2012 11:16 AM UTC

Hi Varalakshmi

I have attached an example of what I am trying to do.

It would appear that it order for this to work, I have to add a dummy parent in order to see all the children as I can only return one node.

I have included a couple of screen shots of what it looks like on the live site so you can see what it would look like for the user. Ideally, after selecting the parent, all the children would appear directly under the parent, rather than an extra step down.

While I could manually build this by iterating through the dataset, it is not ideal from a performance point of view.

Hoping there is an easier way.

Regards

Ross



SyncDemo_1f73ab64.zip


VR Varalakshmi R.S Syncfusion Team May 14, 2012 06:20 AM UTC

Hi Ross,

Thanks for the sample.

We are not able to run the attached sample since database file is missing in this attachment. Can you please provide a complete sample application in order to see this issue?

Regards,
Varalakshmi


RM Ross Macintyre May 14, 2012 07:48 AM UTC

Hi Varalakshmi

You don't need my database for this example as you just need to point a sql instance. The queries used do not actually query any table, so currently the query just points to the master database/

Regards

Ross



VR Varalakshmi R.S Syncfusion Team May 15, 2012 07:01 AM UTC

Hi Ross,

We regret for the inconvenience.

Currently we are not providing support for load on demand using database binding and this is already logged as feature requirement. This will be available in our ES volume 3,2012 release which is scheduled in the month of July. We will get back you once this feature is implemented.

Regards,

Varalakshmi


Loader.
Live Chat Icon For mobile
Up arrow icon