Nov 12, 2010, 10:32 PM
[CLOSED] Buid TreeGrid in Direct Event
hi guys.
I am try to build treegrid when the User click on button. the page will call Direct event.
The tree will build fine when I build it in the page onload but if I try to do the samething in Direct event nothing will happen.
Thank you
I am try to build treegrid when the User click on button. the page will call Direct event.
The tree will build fine when I build it in the page onload but if I try to do the samething in Direct event nothing will happen.
Thank you
<ext:ButtonID="btnSubmit"runat="server"Icon="Magnifier"Text="Submit">
<DirectEvents>
<ClickOnEvent="GetManagersData">
<EventMaskShowMask="true"/>
</Click>
</DirectEvents>
</ext:Button>
<ext:TreeGridrunat="server"Width="780"ID="TrManagers"Height="500">
<Columns>
<ext:TreeGridColumnHeader="Manager"DataIndex="ChildManagerNameID"Width="250"/>
<ext:TreeGridColumnHeader="Pool USD"DataIndex="PoolUSD"Width="80"Align="Right"/>
<ext:TreeGridColumnHeader="Pool Allocated USD"DataIndex="PoolAllocatedUS"Width="100"Align="Right"/>
<ext:TreeGridColumnHeader="Pool Remaining USD"DataIndex="PoolRemainingUSD"Width="100"Align="Right"/>
<ext:TreeGridColumnHeader="Eligible Employees"DataIndex="EligibleEmployee"Width="110"Align="Center"/>
<ext:TreeGridColumnHeader="Employees Planned"DataIndex="PlanedEmployee"Width="110"Align="Center"/>
<ext:TreeGridColumnHeader="% Employees Planned"DataIndex="PercentPlaned"Width="110"Align="Center"/>
</Columns>
</ext:TreeGrid>
protectedvoid Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
BuildTreee(); // This work fine
}
}
protectedvoid GetManagersData(object sender, DirectEventArgs e)
{
BuildTreee() // This doesn't work
}
privatevoid BuildTreee()
{
Ext.Net.TreeNode root = new Ext.Net.TreeNode();
IList<GetBonusSummary> summarys = SummaryObjects.GetBonusSummary(newGuid("C31B2FB4-F583-4D0A-9C67-595FF82588EC"), "111");
List<Summary> Summarys = Summary.BuildBonusSummary(summarys);
List<Summary> lst = Summarys.Where(n => n.ChildManger == 111).ToList();
Summary lst1 = (from s in Summarys.Where(n => n.ChildManger == 111)
select s).First();
TrManagers.Root.Add(root);
Ext.Net.TreeNode ChildNode = AddOneNode(lst1);
root.Nodes.Add(ChildNode);
BuildNodes(Summarys, ChildNode);
BuildNodes(Summarys, ChildNode);
}
private Ext.Net.TreeNode AddOneNode(Summary node)
{
Ext.Net.TreeNode treeNode = new Ext.Net.TreeNode();
treeNode.NodeID = node.ChildManger.ToString();
if (node.NumberOFChildren == 1)
{
treeNode.Leaf = true;
}
else
{
treeNode.IconCls = "FolderGo";
treeNode.Leaf = false;
}
treeNode.CustomAttributes.Add(newConfigItem { Name = "ChildManagerNameID", Value = node.ChildManagerNameID.ToString(), Mode = ParameterMode.Value });
treeNode.CustomAttributes.Add(newConfigItem { Name = "PoolUSD", Value = node.PoolUSD.ToString(), Mode = ParameterMode.Value });
treeNode.CustomAttributes.Add(newConfigItem { Name = "PoolAllocatedUS", Value = node.PoolAllocatedUS.ToString(), Mode = ParameterMode.Value });
treeNode.CustomAttributes.Add(newConfigItem { Name = "PoolRemainingUSD", Value = node.PoolRemainingUSD.ToString(), Mode = ParameterMode.Value });
treeNode.CustomAttributes.Add(newConfigItem { Name = "EligibleEmployee", Value = node.EligibleEmployee.ToString(), Mode = ParameterMode.Value });
treeNode.CustomAttributes.Add(newConfigItem { Name = "PlanedEmployee", Value = node.PlanedEmployee.ToString(), Mode = ParameterMode.Value });
treeNode.CustomAttributes.Add(newConfigItem { Name = "PercentPlaned", Value = node.PercentPlaned.ToString() + "%", Mode = ParameterMode.Value });
return treeNode;
}
privatevoid BuildNodes(List<Summary> nodes, Ext.Net.TreeNode parent)
{
// Stopped here I want to add children to tree
int parentId = Convert.ToInt32(parent.NodeID);
List<Summary> Children = nodes.Where(x => x.ManagerID == parentId).ToList();
foreach (Summary node in Children)
{
Ext.Net.TreeNode ChildNode = AddOneNode(node);
parent.Nodes.Add(ChildNode);
if (node.NumberOFChildren > 1)
{
BuildNodes(nodes, ChildNode);
}
}
}
Last edited by Daniil; Nov 16, 2010 at 7:46 AM.
Reason: Please use [CODE] tags, [CLOSED]