Welcome Guest Search | Active Topics | Sign In | Register

Treeview populate on demand Options
Marco
Posted: Friday, April 15, 2011 9:27:19 AM
Rank: Member
Groups: Member

Joined: 4/15/2011
Posts: 19
Hello,

Can you please help using a datatable for populate treeview nodes on demand?

I navigated on your demo, and i found the explanation for binding menu from datatable:
DataTable binding.

Here i found the code for populate on demand from an existent directory structure, but how can i do the same binding from datatable having the first example schema?

Thanks
eo_support
Posted: Friday, April 15, 2011 9:46:41 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

This is something you will need to work out yourself. The key is you will need to get all the child records from your database and then create child tree node based on your data. We can not do it for you because everybody's database structure can be different.

Thanks!
Marco
Posted: Friday, April 15, 2011 9:56:33 AM
Rank: Member
Groups: Member

Joined: 4/15/2011
Posts: 19
Can you just please give an example?

If i've got the same table of your example (This one), how can i populate on demand?

This is the table:

DataTable table = ds.Tables.Add("Folders");
DataColumn folderID = table.Columns.Add("FolderID", typeof(int));
DataColumn parentFolderID = table.Columns.Add("ParentFolderID", typeof(int));
DataColumn folderName = table.Columns.Add("FolderName", typeof(string));

table.Rows.Add(new object[] { 1, null, "Root" });
table.Rows.Add(new object[] { 2, 1, "My Documents" });
table.Rows.Add(new object[] { 3, 1, "Windows" });
table.Rows.Add(new object[] { 4, 3, "System32" });
table.Rows.Add(new object[] { 5, 3, "Temp" });

eo_support
Posted: Friday, April 15, 2011 10:00:40 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
No. We do not do that. How to access your database and create TreeNode object depending on your database structure is part of your project, so this is code that you are responsible for. We do not write code for our customers so we do not do that. Even if we were willing to do it, we would not know how to do it because we do not know how to access your database. We don't even know what kind of database you use.

Thanks
Marco
Posted: Friday, April 15, 2011 10:07:03 AM
Rank: Member
Groups: Member

Joined: 4/15/2011
Posts: 19
Ok, thanks anyway. Just another little trouble:

I've got this:

function myFunc() {
__DoPostBack('__Page', '');
}

<eo:TreeView ClientSideOnCheckStateChanging="myFunc()" ... ></eo:TreeView>


But on checkbox click DoPostBack doesn't fire. Where do i wrong?
eo_support
Posted: Friday, April 15, 2011 10:30:30 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

All our client side event handler takes a function name, not a function call. It should be "myFunc", not "myFunc()".

You do not want to raises a post back inside ClientSideOnCheckStateChanging because the control is in the middle of a state change when your handler is called. If you do need to postback when user change states, you can use setTimeout to delay the call:

Code: JavaScript
function myFunc()
{
    //Use setTimeout to delay the actual code
    setTimeout(function()
    {
        __DoPostBack('__Page', ''); 
    }, 100);
}


This way your "myFunc" will return first and __DoPostBack will be triggered later.

Thanks!
andry
Posted: Friday, April 15, 2011 11:07:49 AM
Rank: Newbie
Groups: Member

Joined: 4/15/2011
Posts: 1
Hello,

When i create tree on demand, i call for all children of current node parentNode.ChildNodes.Add(child) method. In this phase i know if child is a leaf or another parentnode, but the treeview gives again the opportunity to expand the new node showing the + icon.

How can i hide this icon if i know this child is a leaf?
Marco
Posted: Friday, April 15, 2011 11:23:37 AM
Rank: Member
Groups: Member

Joined: 4/15/2011
Posts: 19
I still have problems :(

ASPX:

<head runat="server">
<title></title>
<script type="text/javascript">
function myFunc() {
//Use setTimeout to delay the actual code
setTimeout(function() {
__DoPostBack('__Page', '');
}, 100);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<eo:TreeView ID="tv1" runat="server" RaisesServerEvent ="True"
ClientSideOnCheckStateChanging="myFunc" onitemcheckstatechanged="tv1_ItemCheckStateChanged">
<CheckBoxImages Margin="3" Visible="True" />
<TopGroup>
<Nodes>
<eo:TreeNode ImageUrl="00030303" ShowCheckBox="True" Text="Node">
</eo:TreeNode>
</Nodes>
</TopGroup>
</eo:TreeView>
</div>
</form>
</body>



C#
protected void Page_Load(object sender, EventArgs e)
{

}

protected void tv1_ItemCheckStateChanged(object sender, EO.Web.TreeNodeCheckStateChangedEventArgs e)
{

}



postback doesn't fire, i check it with a breakpoint on page_load.
eo_support
Posted: Friday, April 15, 2011 11:29:34 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

For the plus-signs for a TreeNode, you will need to set the node's PopulateOnDemand to false if you already know it's a leaf node and do not need to populate further.

For the post back and event firing problem, you will need to troubleshoot yourself. The TreeView fires ClientSideOnCheckStateChanging and that's where it ends. Whatever happens afterwards would be all yours.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.