Apr 24, 2009, 6:02 PM
[CLOSED] TreePanel + Listeners + Click/BeforeClick
I noticing that Click and BeforeClick on the TreePanel have the same behavior. I don't know if this is an ExtJS problem or a Coolite problem.
Here is some code to demonostrate the problem. Here is the .aspx page:
If I fire the Click listener event, then I how am I suppose to get the currently selected node (or it's id)?
Thanks.
Here is some code to demonostrate the problem. Here is the .aspx page:
<script language="javascript" type="text/javascript">
var PanelEvents = {
getSelectModel: function(panelName)
{
try {
var panel = Ext.getCmp(panelName);
alert(panel.selModel.getSelectedNode().id);
} catch(err) {
Ext.Msg.alert('Javascript Error', err.description);
}
}
}
</script>
<ext:TreePanel ID="tpPanel" runat="server" AutoScroll="true" Border="false" RootVisible="false" IDMode="Static">
<Loader>
<ext:PageTreeLoader OnNodeLoad="tpPanel_NodeLoad" />
</Loader>
<Listeners>
<Click Handler="PanelEvents.getSelectModel('tpPanel');" />
</Listeners>
</ext:TreePanel>
Here is the code behind:protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack && !Ext.IsAjaxRequest)
{
this.BuildUsersTree();
}
}
protected void tpPanel_NodeLoad(object sender, NodeLoadEventArgs e)
{
if (!string.IsNullOrEmpty(e.NodeID))
{
// Do some stuff here
}
}
private void BuildUsersTree()
{
IntUsers.Users user = new IntUsers.Users(this.ConnectionString);
DataTable users = user.GetUsers();
TreeNode nodeUsers = new TreeNode("Users", Icon.Group);
tpPanel.Users.Add(nodeUsers);
if (users != null && users.Rows.Count > 0)
{
foreach(DataRow data in users.Rows)
{
string fullName = Convert.ToString(data["FullName"]);
string userId = Convert.ToString(data["UserId"]);
bool isOnline = Convert.ToBoolean(data["IsOnline"]);
Icon statusIcon = (isOnline) ? Icon.StatusOnline : Icon.StatusOffline;
AsyncTreeNode userNode = new AsyncTreeNode("ur" + userId, fullName);
userNode.Icon = statusIcon;
nodeUsers.Nodes.add(userNode);
}
}
}
Now, the problem is that the selectedNode() isn't available on the Click listener at this point. It's excibiting the same behavior as a BeforeClick listener.If I fire the Click listener event, then I how am I suppose to get the currently selected node (or it's id)?
Thanks.