Выбор узла Ext.Net TreePanel не отображается или не виден - PullRequest
1 голос
/ 11 ноября 2011
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Window ID="UploadWindow" IDMode="Client" runat="server" Width="550" AutoHeight="true"
    Title="Upload a File">
    <Items>
        <ext:Panel ID="Panel1" runat="server" LabelWidth="200" ButtonAlign="Left" Padding="10" Layout="FormLayout">
            <Items>
                <ext:FileUploadField ID="FileUploadField1" runat="server" FieldLabel="Please browse a file to upload"
                    ButtonOnly="false" Width="300" />
                <ext:TreePanel ID="FolderTree" runat="server" Height="200" UseArrows="true" FieldLabel="Please select a directory"
                    AutoScroll="true" Animate="true" EnableDD="true" ContainerScroll="true" RootVisible="false">
                </ext:TreePanel>
            </Items>
            <Buttons>
                <ext:Button ID="Button1" runat="server" Text="Upload" />
            </Buttons>
        </ext:Panel>
    </Items>
</ext:Window>

Привет, все работает нормально и нормально, кроме «ВЫБРАННОГО УЗЛА НЕ ВЫДЕЛЕНО» от щелчка мыши (один или два щелчка) и навигации по клавиатуре.

РЕДАКТИРОВАТЬ

Код для заполнения триода:

protected void Page_Load(object sender, EventArgs e)
{
    Ext.Net.TreeNode root = this.CreateNode(SiteMap.RootNode);
    root.Draggable = false;
    root.Expanded = true;
    FolderTree.Root.Add(root);
    FolderTree.ExpandAll();
}

/// <summary>
/// Creates nodes from sitemap data
/// </summary>
/// <param name="siteMapNode">Pass the root node of Web.sitemap</param>
/// <returns></returns>
private Ext.Net.TreeNode CreateNode(SiteMapNode siteMapNode)
{
    Ext.Net.TreeNode treeNode = new Ext.Net.TreeNode();
    treeNode.NodeID = siteMapNode.Key;
    treeNode.Text = siteMapNode.Title;
    treeNode.Qtip = siteMapNode.Description;
    //treeNode.Href = siteMapNode.Url;
    treeNode.Icon = this.GetIcon(siteMapNode["menuId"].ToString(new CultureInfo("en-Us")));
    string iconCls = GetIconCls(treeNode.Icon);

    //System.Windows.Forms.MessageBox.Show(iconCls);
    treeNode.Listeners.Click.Handler = string.Format(new CultureInfo("en-US"), "#{{MainPanel}}.load('{0}');#{{MainPanel}}.setIconClass('{1}');#{{MainPanel}}.setTitle('{2}');", siteMapNode.Url, iconCls, siteMapNode.Title);

    SiteMapNodeCollection children = siteMapNode.ChildNodes;
    if (children != null && children.Count > 0)
    {
        foreach (SiteMapNode mapNode in siteMapNode.ChildNodes)
        {
            treeNode.Nodes.Add(this.CreateNode(mapNode));
        }
    }
    return treeNode;
}

private string GetIconCls(Ext.Net.Icon icon)
{
    string iconCls = this.ResourceManager1.GetIconClass(icon);
    int pos = iconCls.IndexOf("{", StringComparison.OrdinalIgnoreCase);
    return iconCls.Substring(1, pos - 1);
}

Спасибо и всего наилучшего.

Ответы [ 2 ]

1 голос
/ 12 ноября 2011

Что такое

treeNode.Listeners.Click.Handler = string.Format(new CultureInfo("en-US"), "#{{MainPanel}}.load('{0}');#{{MainPanel}}.setIconClass('{1}');#{{MainPanel}}.setTitle('{2}');", siteMapNode.Url, iconCls, siteMapNode.Title);

делает

Пожалуйста, удалите эту строку, так как нет объекта с именем "MainPanel" и посмотрите, решена ли она.

1 голос
/ 12 ноября 2011

Я использовал ваш код с узлами из examples.ext.net. И все хорошо. Можете ли вы показать, как вы устанавливаете узлы дерева? А какую версию Ext.NET вы используете?

<ext:ResourceManager ID="ResourceManager1" runat="server" />

<form id="Form1" runat="server">
    <ext:Window ID="UploadWindow" IDMode="Client" runat="server" Width="550" AutoHeight="true"
        Title="Upload a File">
        <Items>
            <ext:Panel ID="Panel1" runat="server" LabelWidth="200" ButtonAlign="Left" Padding="10" Layout="FormLayout">
                <Items>
                    <ext:FileUploadField ID="FileUploadField1" runat="server" FieldLabel="Please browse a file to upload"
                        ButtonOnly="false" Width="300" />
                    <ext:TreePanel ID="FolderTree" runat="server" Height="200" UseArrows="true" FieldLabel="Please select a directory"
                        AutoScroll="true" Animate="true" EnableDD="true" ContainerScroll="true" RootVisible="false">
                            <Root>
                                <ext:TreeNode Text="Composers" Expanded="true">
                                    <Nodes>
                                        <ext:TreeNode Text="Beethoven" Icon="UserGray" >
                                            <Nodes>
                                                <ext:TreeNode Text="Concertos">
                                                    <Nodes>
                                                        <ext:TreeNode Text="No. 1 - C" Icon="Music" />
                                                        <ext:TreeNode Text="No. 2 - B-Flat Major" Icon="Music" />
                                                        <ext:TreeNode Text="No. 3 - C Minor" Icon="Music" />
                                                        <ext:TreeNode Text="No. 4 - G Major" Icon="Music" />
                                                        <ext:TreeNode Text="No. 5 - E-Flat Major" Icon="Music" />
                                                    </Nodes>
                                                </ext:TreeNode>
                                                <ext:TreeNode Text="Quartets">
                                                    <Nodes>
                                                        <ext:TreeNode Text="Six String Quartets" Icon="Music" />
                                                        <ext:TreeNode Text="Three String Quartets" Icon="Music" />
                                                        <ext:TreeNode Text="Grosse Fugue for String Quartets" Icon="Music" />
                                                    </Nodes>
                                                </ext:TreeNode>
                                                <ext:TreeNode Text="Sonatas">
                                                    <Nodes>
                                                        <ext:TreeNode Text="Sonata in A Minor" Icon="Music" />
                                                        <ext:TreeNode Text="sonata in F Major" Icon="Music" />
                                                    </Nodes>
                                                </ext:TreeNode>
                                                <ext:TreeNode Text="Symphonies">
                                                    <Nodes>
                                                        <ext:TreeNode Text="No. 1 - C Major" Icon="Music" />
                                                        <ext:TreeNode Text="No. 2 - D Major" Icon="Music" />
                                                        <ext:TreeNode Text="No. 3 - E-Flat Major" Icon="Music" />
                                                        <ext:TreeNode Text="No. 4 - B-Flat Major" Icon="Music" />
                                                        <ext:TreeNode Text="No. 5 - C Minor" Icon="Music" />
                                                        <ext:TreeNode Text="No. 6 - F Major" Icon="Music" />
                                                        <ext:TreeNode Text="No. 7 - A Major" Icon="Music" />
                                                        <ext:TreeNode Text="No. 8 - F Major" Icon="Music" />
                                                        <ext:TreeNode Text="No. 9 - D Minor" Icon="Music" />
                                                    </Nodes>
                                                </ext:TreeNode>
                                            </Nodes>
                                        </ext:TreeNode>
                                        <ext:TreeNode Text="Brahms" Icon="UserGray">
                                            <Nodes>
                                                <ext:TreeNode Text="Concertos">
                                                    <Nodes>
                                                        <ext:TreeNode Text="Violin Concerto" Icon="Music" />
                                                        <ext:TreeNode Text="Double Concerto - A Minor" Icon="Music" />
                                                        <ext:TreeNode Text="Piano Concerto No. 1 - D Minor" Icon="Music" />
                                                        <ext:TreeNode Text="Piano Concerto No. 2 - B-Flat Major" Icon="Music" />
                                                    </Nodes>
                                                </ext:TreeNode>
                                                <ext:TreeNode Text="Quartets">
                                                    <Nodes>
                                                        <ext:TreeNode Text="Piano Quartet No. 1 - G Minor" Icon="Music" />
                                                        <ext:TreeNode Text="Piano Quartet No. 2 - A Major" Icon="Music" />
                                                        <ext:TreeNode Text="Piano Quartet No. 3 - C Minor" Icon="Music" />
                                                        <ext:TreeNode Text="Piano Quartet No. 3 - B-Flat Minor" Icon="Music" />
                                                    </Nodes>
                                                </ext:TreeNode>
                                                <ext:TreeNode Text="Sonatas">
                                                    <Nodes>
                                                        <ext:TreeNode Text="Two Sonatas for Clarinet - F Minor" Icon="Music" />
                                                        <ext:TreeNode Text="Two Sonatas for Clarinet - E-Flat Major" Icon="Music" />
                                                    </Nodes>
                                                </ext:TreeNode>
                                                <ext:TreeNode Text="Symphonies">
                                                    <Nodes>
                                                        <ext:TreeNode Text="No. 1 - C Minor" Icon="Music" />
                                                        <ext:TreeNode Text="No. 2 - D Minor" Icon="Music" />
                                                        <ext:TreeNode Text="No. 3 - F Major" Icon="Music" />
                                                        <ext:TreeNode Text="No. 4 - E Minor" Icon="Music" />
                                                    </Nodes>
                                                </ext:TreeNode>
                                            </Nodes>
                                        </ext:TreeNode>
                                        <ext:TreeNode Text="Mozart" Icon="UserGray">
                                            <Nodes>
                                                <ext:TreeNode Text="Concertos">
                                                    <Nodes>
                                                        <ext:TreeNode Text="Piano Concerto No. 12" Icon="Music"  />
                                                        <ext:TreeNode Text="Piano Concerto No. 17" Icon="Music"  />
                                                        <ext:TreeNode Text="Clarinet Concerto" Icon="Music"  />
                                                        <ext:TreeNode Text="Violin Concerto No. 5" Icon="Music"  />
                                                        <ext:TreeNode Text="Violin Concerto No. 4" Icon="Music"  />
                                                    </Nodes>
                                                </ext:TreeNode>
                                            </Nodes>
                                        </ext:TreeNode>
                                    </Nodes>
                                </ext:TreeNode>
                            </Root>
                    </ext:TreePanel>
                </Items>
                <Buttons>
                    <ext:Button ID="Button1" runat="server" Text="Upload" />
                </Buttons>
            </ext:Panel>
        </Items>
    </ext:Window>
</form>
...