#c# #asp.net #ext.net
#c# #asp.net #ext.net
Вопрос:
<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>
Привет, все работает нормально, за исключением того, что «ВЫБРАННЫЙ УЗЕЛ НЕ выделен» при щелчке мышью (одинарный или двойной щелчок) и навигации с клавиатуры.
Редактировать
Кодовая ссылка для заполнения treenode является
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 amp;amp; 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);
}
Спасибо вам и с уважением.
Комментарии:
1. Я также пробовал свойство Selectable =»true», но безуспешно.
Ответ №1:
Что такое
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», и посмотрите, решена ли она.
Ответ №2:
Я использовал ваш код с узлами из examples.ext.net . И все в порядке. Можете ли вы показать, как вы устанавливаете узлы дерева? И какая версия Ext.СЕТЬ, которую вы используете?
<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>