我有一个包含 TreeView 的 ComponentArt:NavBar,我希望用户能够扩展此 NavBar 的宽度,但只能扩展到内容的最大宽度。
<ComponentArt:NavBar Height="500px" ID="nbMenu" meta:resourcekey="nbMenu" runat="server" ClientTarget="Auto" CssClass="NavBar"
DefaultItemLookId="TopItemLook" DefaultItemSpacing="0" DefaultItemTextAlign="left" DefaultSelectedItemLookId="ExpandedTopLook"
ExpandSinglePath="True" ImagesBaseUrl="../Images/Icons/MenuItems/" Width="300px" BorderStyle="None" DefaultChildSelectedItemLookId="TopItemHover"
ScrollUpImageUrl="scrollup.gif" ScrollDownImageUrl="scrolldown.gif" ScrollUpHoverImageUrl="scrollup_hover.gif" ScrollDownHoverImageUrl="scrolldown_hover.gif"
ScrollUpActiveImageUrl="scrollup_active.gif" ScrollDownActiveImageUrl="scrolldown_active.gif" ScrollUpImageWidth="16" ScrollUpImageHeight="16"
ScrollDownImageWidth="16" ScrollDownImageHeight="16" ExpandDuration="350" CollapseDuration="350" ExpandTransition="Fade"
CollapseTransition="Fade" FullExpand="true" ClientScriptLocation="~/client_scripts/">
<ItemLooks>
<ComponentArt:ItemLook CssClass="TopItem" ExpandedCssClass="TopItemHover" HoverCssClass="TopItemHover" LookId="TopItemLook" />
<ComponentArt:ItemLook CssClass="Level2Item" ExpandedCssClass="TopItemHover" HoverCssClass="Level2ItemHover" LabelPaddingTop="10px" LookId="Level2ItemLook" />
<ComponentArt:ItemLook CssClass="CollapseTop" HoverCssClass="CollapseTopHover" LookId="ExpandedTopLook" />
<ComponentArt:ItemLook CssClass="CollapseLevel2" HoverCssClass="CollapseLevel2Hover" LookId="ExpandedLevel2Look" />
</ItemLooks>
<ServerTemplates>
<ComponentArt:NavigationCustomTemplate ID="TreeViewTemplate" meta:resourcekey="TreeViewTemplate">
<Template>
<asp:PlaceHolder ID="phTreeView" meta:resourcekey="phTreeView" runat="server"></asp:PlaceHolder>
</Template>
</ComponentArt:NavigationCustomTemplate>
</ServerTemplates>
</ComponentArt:NavBar>
用于设置 TreeView 本身宽度的属性:
private void BuildMenu(bool buildPartial)
{
int employeeIndex;
// get the employee index
employeeIndex = BuildEmployeeMenu();
//Add a tree view to the menu item
var tvBuilder = new TreeViewBuilder(TreeViewBuilder.Template.Version1);
ComponentArt.Web.UI.TreeView tv = tvBuilder.CreateTreeView();
tv.Width = Unit.Percentage(95);
var dt = Signify.Framework.Security.Menu.SelectMenuManageEmployees();
if (buildPartial)
{
BuildMenuTree(ref tv, ref dt, "EventCode IN ('" + Signify.Framework.Security.Menu.MenuItemList.MENU_HUMANRESOURCES_PERSONNEL_MANAGEEMPLOYEES_EMPLOYEES_ADMINISTRATION.ToString() + "','" + Signify.Framework.Security.Menu.MenuItemList.MENU_HUMANRESOURCES_PERSONNEL_MANAGEEMPLOYEES_EMPLOYEES_MASTERDATA.ToString() + "')");
}
else
{
DataRow[] dr;
dr = dt.Select("EventCode = '" + Signify.Framework.Security.Menu.MenuItemList.MENU_HUMANRESOURCES_PERSONNEL_MANAGEEMPLOYEES_EMPLOYEES.ToString() + "'");
if (dr.Length > 0)
{
BuildMenuTree(ref tv, ref dt, "FKstyMenuObjectID = " + dr[0]["ObjectID"].ToString());
}
}
templateGenerator.GenerateTree(nbMenu.Items[employeeIndex].Items[0], tv, "GenerateTree", "phTreeView");
if (!menuItemFound)
hfMenuItemSelectedStartUrl.Value = "";
hfTreeviewClientID.Value = tv.ClientID;
}
我需要将树视图菜单扩展到最大宽度,并且不允许用户进一步扩展。