Oct 07, 2012, 8:50 PM
[CLOSED] TreePanel + Root
Hello
I have the problem with root item of the treepanel ( treegrid)
So far I found this:
- Root must be present ( otherwise js error is thrown on rendering)
- The attributes of root item is impossible to change
here is my simple example what I want to achieve - in short - I want to have root item text to be dynamic according the text on previous tab.
As well I don't want to load the tree on IsPostBack==false, but when the tab is activated.
The problem is that text of root item does not changes - I moreless undertand that, simply after rendering it seems to be immutable, which is ok.
But how to deal with that? I tried to hide the root item (the idea was that my "dynamic" root item will be the first child item but the problem was that the ReadData event was then fired immediatelly when the page was rendered - and never again. Maybe some magic with 'beforeload' event and reload method will work here?
The example code:
I have the problem with root item of the treepanel ( treegrid)
So far I found this:
- Root must be present ( otherwise js error is thrown on rendering)
- The attributes of root item is impossible to change
here is my simple example what I want to achieve - in short - I want to have root item text to be dynamic according the text on previous tab.
As well I don't want to load the tree on IsPostBack==false, but when the tab is activated.
The problem is that text of root item does not changes - I moreless undertand that, simply after rendering it seems to be immutable, which is ok.
But how to deal with that? I tried to hide the root item (the idea was that my "dynamic" root item will be the first child item but the problem was that the ReadData event was then fired immediatelly when the page was rendered - and never again. Maybe some magic with 'beforeload' event and reload method will work here?
The example code:
<script>
function tabChanged(panel,newTab) {
if(newTab.id=='<%=treeAssignedParts.ClientID %>')
<%=treeAssignedParts.ClientID %>.getRootNode.expand();
}
</script>
<form runat="server">
<ext:ResourceManager runat="server" Theme="Gray" Namespace="" />
<ext:TabPanel runat="server" ActiveTabIndex="0">
<Listeners>
<TabChange Fn="tabChanged"></TabChange>
</Listeners>
<Items>
<ext:Panel Title="Tab1">
<Items>
<ext:TextField runat="server" ID="txt" Text="from textbox"/>
</Items>
</ext:Panel>
<ext:TreePanel ID="treeAssignedParts" runat="server" Height="150" RootVisible="true" Title="Tab with tree" >
<Fields>
<ext:ModelField Name="itemId" />
</Fields>
<Store>
<ext:TreeStore ID="TreeStore1" runat="server" OnReadData="store_readData" >
<Proxy>
<ext:PageProxy />
</Proxy>
</ext:TreeStore>
</Store>
<Root>
<ext:Node >
<CustomAttributes>
<ext:ConfigItem Name="itemId" Value="xxx" Mode="Value"/>
</CustomAttributes>
</ext:Node>
</Root>
<ColumnModel>
<Columns>
<ext:TreeColumn ID="TreeColumn1" Header="ItemId" Width="90" DataIndex="itemId" SortType="AsInt" runat="server">
</ext:TreeColumn>
</Columns>
</ColumnModel>
</ext:TreePanel>
</Items>
</ext:TabPanel>
protected void store_readData(object sender, NodeLoadEventArgs e)
{
treeAssignedParts.Root[0].Text = txt.Text;
e.Nodes.Add(new Node()
{
CustomAttributes = {
new ConfigItem("itemId","First CHild",ParameterMode.Value)
}
});
}
Last edited by Daniil; Oct 12, 2012 at 6:07 AM.
Reason: [CLOSED]