PDA

View Full Version : [CLOSED] Problem with inherited treepanel and xmldatabinding



infonext
Jun 26, 2013, 9:07 AM
Hi all,

previously i used the static definition of treepanel (built in markup) and overrided the "OnInit" method of treepanel for iterate nodes and perform some actions based on custom attributes of nodes.
Then i tested the new CustomAttributeBinding, but if i check the treepanel.Root property, the node collection is empty.
Wich method i need to override to be sure that collection is filled?

Thanks

Best regards

Daniil
Jun 26, 2013, 12:50 PM
Hi @infonext,

You can use a Store's DataBound event.

Example

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">

protected void TreeStore_DataBound(object sender, EventArgs e)
{
X.Msg.Alert("", (sender as TreeStore).Root[0].Text).Show();
}
</script>

<!DOCTYPE html>
<html>
<head runat="server">
<title>Xml File Loading - Ext.NET Examples</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />

<asp:XmlDataSource ID="XmlDataSource1" runat="server"
DataFile="authors.xml">
</asp:XmlDataSource>

<ext:TreePanel runat="server" Height="300" Width="250">
<Store>
<ext:TreeStore runat="server" DataSourceID="XmlDataSource1" OnDataBound="TreeStore_DataBound">
<DataBindings>
<ext:NodeBinding DataMember="Authors" Text="Authors List" />
<ext:NodeBinding DataMember="Author" TextField="name" />
<ext:NodeBinding DataMember="blog" HrefField="url" TextField="url" Leaf="true" />
</DataBindings>
</ext:TreeStore>
</Store>
</ext:TreePanel>
</form>
</body>
</html>

authors.xml

<?xml version="1.0" encoding="utf-8" ?>
<Authors>
<Author name="Author 1">
<blog url="http://ext.net/blogs/author1/" />
</Author>
<Author name="Author 2">
<blog url="http://ext.net/blogs/author2/" />
</Author>
<Author name="Author 3">
<blog url="http://ext.net/blogs/author3/" />
</Author>
<Author name="Author 4">
<blog url="http://ext.net/blogs/author4/" />
</Author>
</Authors>

infonext
Jun 26, 2013, 2:11 PM
Hi @infonext,

You can use a Store's DataBound event.

Example

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">

protected void TreeStore_DataBound(object sender, EventArgs e)
{
X.Msg.Alert("", (sender as TreeStore).Root[0].Text).Show();
}
</script>

<!DOCTYPE html>
<html>
<head runat="server">
<title>Xml File Loading - Ext.NET Examples</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />

<asp:XmlDataSource ID="XmlDataSource1" runat="server"
DataFile="authors.xml">
</asp:XmlDataSource>

<ext:TreePanel runat="server" Height="300" Width="250">
<Store>
<ext:TreeStore runat="server" DataSourceID="XmlDataSource1" OnDataBound="TreeStore_DataBound">
<DataBindings>
<ext:NodeBinding DataMember="Authors" Text="Authors List" />
<ext:NodeBinding DataMember="Author" TextField="name" />
<ext:NodeBinding DataMember="blog" HrefField="url" TextField="url" Leaf="true" />
</DataBindings>
</ext:TreeStore>
</Store>
</ext:TreePanel>
</form>
</body>
</html>

authors.xml

<?xml version="1.0" encoding="utf-8" ?>
<Authors>
<Author name="Author 1">
<blog url="http://ext.net/blogs/author1/" />
</Author>
<Author name="Author 2">
<blog url="http://ext.net/blogs/author2/" />
</Author>
<Author name="Author 3">
<blog url="http://ext.net/blogs/author3/" />
</Author>
<Author name="Author 4">
<blog url="http://ext.net/blogs/author4/" />
</Author>
</Authors>

Hi Daniil,
now it works :)

Thanks you!

You can close discussion.