FineUI 官方论坛
标题:
可能是树 的右键菜单bug
[打印本页]
作者:
owenhy
时间:
2016-2-1 21:54
标题:
可能是树 的右键菜单bug
按照专业版范例写的树的右键菜单。菜单显示异常。浏览器的菜单没有隐藏。比对了几次没发现例子中特别的设置。
[attach]8524[/attach]
代码如下:
<asp:Content ID="Content2" ContentPlaceHolderID="detail" runat="server">
<f:RegionPanel ID="RegionPanel1" ShowBorder="false" runat="server">
<Regions>
<f:Region ID="Region1" Split="true" ShowHeader="false" EnableCollapse="true" runat="server" Layout="Fit" Position="Left" Width="250px" >
<Items>
<f:TabStrip ID="TabStrip1" ShowBorder="true" TabPosition="Top" EnableTabCloseMenu="false" ActiveTabIndex="0" runat="server" Width="250px" RegionPosition="Center" >
<Tabs>
<f:Tab ID="Tab1" Title="品号分类" BodyPadding="5px" Layout="Fit" runat="server">
<Items>
<f:Tree ID="flyTreeView" EnableCollapse="true" OnNodeLazyLoad="Tree1_NodeLazyLoad" OnNodeCommand="Tree1_NodeCommand" RegionSplit="false"
Width="250px" Title="品号分类" ShowBorder="true" ShowHeader="false" BodyPadding="10px" runat="server" AutoLeafIdentification="false" AutoScroll="true" >
<Listeners>
<f:Listener Event="beforenodecontextmenu" Handler="onTreeNodeContextMenu" />
</Listeners>
</f:Tree>
</Items>
</f:Tab>
<f:Tab ID="Tab2" Title="查询" BodyPadding="5px" Layout="Fit" runat="server">
<Items>
</Items>
</f:Tab>
</Tabs>
</f:TabStrip>
</Items>
</f:Region>
<f:Region ID="Region2" Split="true" runat="server" EnableCollapse="true" Layout="Fit" Position="Center" ShowHeader="false">
<Items>
<f:Form ID="SimpleForm1" ShowBorder="true" ShowHeader="false" AutoScroll="true" BodyPadding="3px"
runat="server" Height="150px" RegionPosition="Center" Layout="Region" >
<Toolbars>
<f:Toolbar ID="Toolbar1" runat="server">
<Items>
</Items>
</f:Toolbar>
</Toolbars>
<Items>
<f:Grid ID="Grid_Main" EnableCollapse="false" PageSize="10"
AllowPaging="true" AutoScroll="true" runat="server" EnableCheckBoxSelect="true"
ShowPagingMessage="true" DataKeyNames="OID,RowValue" IsDatabasePaging="true" AllowCellEditing="false"
EnableMultiSelect="false" OnRowDataBound="GridDetail_RowDataBound" Title="品号明细"
ShowBorder="true" ShowHeader="true" RegionPosition="Center" >
<Columns>
</Columns>
</f:Grid>
</Items>
</f:Form>
</Items>
</f:Region>
</Regions>
</f:RegionPanel>
<f:Menu ID="Menu1" runat="server">
<Items>
<f:MenuButton ID="btnExpandNode" EnablePostBack="false" runat="server" Text="展开全部">
<Listeners>
<f:Listener Event="click" Handler="onExpandNode" />
</Listeners>
</f:MenuButton>
<f:MenuButton ID="btnCollapseNode" EnablePostBack="false" runat="server" Text="折叠全部">
<Listeners>
<f:Listener Event="click" Handler="onCollapseNode" />
</Listeners>
</f:MenuButton>
</Items>
<Listeners>
<f:Listener Event="show" Handler="onMenuShow" />
</Listeners>
</f:Menu>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="footer" runat="server">
<script>
///此变量将传递给母模板的脚本处理
var gridClientID = '<%= Grid_Main.ClientID %>';
F.ready(function () {
})
var treeID = '<%= flyTreeView.ClientID %>';
var menuID = '<%= Menu1.ClientID %>';
// 保存当前菜单对应的树节点ID
var currentNodeId;
// 返回false,来阻止浏览器右键菜单
function onTreeNodeContextMenu(event, nodeId) {
currentNodeId = nodeId;
F(menuID).show();
return false;
}
// 设置所有菜单项的禁用状态
function setMenuItemsDisabled(disabled) {
var menu = F(menuID);
$.each(menu.items, function (index, item) {
item.setDisabled(disabled);
});
}
// 显示菜单后,检查是否禁用菜单项
function onMenuShow() {
if (currentNodeId) {
var tree = F(treeID);
var nodeData = tree.getNodeData(currentNodeId);
if (nodeData.leaf) {
setMenuItemsDisabled(true);
} else {
setMenuItemsDisabled(false);
}
}
}
function onExpandNode() {
if (currentNodeId) {
F(treeID).expandNode(currentNodeId, true);
}
}
function onCollapseNode() {
if (currentNodeId) {
F(treeID).collapseNode(currentNodeId, true);
}
}
</script>
</asp:Content>
复制代码
欢迎光临 FineUI 官方论坛 (https://fineui.com/BBS/)
Powered by Discuz! X3.4