PDA

View Full Version : [CLOSED] Treepanel root visible



softmachine2011
Sep 12, 2012, 8:37 AM
Hi,

In v1.x I perform this to set root node visibility.



myTree.rootVisible = true || false; //My custom condition
myTree.setRootNode(node);


Now, with myTree with property RootVisible setted to false in ASPX markup, although I change this value like in the example, when treepanel redraw in setRootNode, doesn't shows me root node when condition is true.

How I can do this now, I don't see any method in ext docs.

Daniil
Sep 12, 2012, 11:32 AM
Hi,

Well, it is not documented behavior in ExtJS 3. The rootVisible property is private.
http://docs.sencha.com/ext-js/3-4/#!/api/Ext.tree.TreePanel-property-rootVisible

I can't see an API possibility to do it in ExtJS 4 as well, but I can suggest the following solution.

Example

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

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

<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.NET v2 Example</title>

<script type="text/javascript">
var setRootNode = function () {
var tree = App.TreePanel1,
view = tree.getView(),
newRoot = {
text : "new root",
leaf : true
};

view.rootVisible = view.store.rootVisible = true;
tree.setRootNode(newRoot);
view.refresh();
};
</script>
</head>
<body>
<ext:ResourceManager runat="server" />

<ext:TreePanel
ID="TreePanel1"
runat="server"
RootVisible="false"
Height="100">
<Root>
<ext:Node Text="Root" Leaf="true" />
</Root>
</ext:TreePanel>

<ext:Button runat="server" Text="setRootNode">
<Listeners>
<Click Fn="setRootNode" />
</Listeners>
</ext:Button>
</body>
</html>

softmachine2011
Sep 12, 2012, 11:38 AM
Great!

This piece of code do the trick:



var view = treeOrganigrama.getView();
view.rootVisible = view.store.rootVisible = nodeId > 0;
treeOrganigrama.setRootNode(node);


Thanks!