/// <summary> /// 设置按钮可用状态 /// </summary> /// <param name="view"></param> /// <param name="barItemKey">按钮标识</param> /// <param name="bEnabled">可用性</param> /// <param name="barOwnerKey">工具条拥有者标识,单据主工具条不用传值,表格工具条请传表格标识,其它独立工具条请传工具条标识</param> public static void SetBarItemEnabled(this IDynamicFormView view, string barItemKey, bool bEnabled, string barOwnerKey = "") { Appearance ap = null; if (!string.IsNullOrWhiteSpace(barOwnerKey)) { ap = view.LayoutInfo.GetAppearance(barOwnerKey); } BarItemControl barItem = null; if (ap == null) { barItem = view.GetMainBarItem(barItemKey); if (barItem != null) { barItem.Enabled = bEnabled; } } foreach (var entityAp in view.LayoutInfo.GetEntityAppearances()) { if (entityAp is HeadEntityAppearance || entityAp is SubHeadEntityAppearance) { continue; } if (barOwnerKey.IsNullOrEmptyOrWhiteSpace() || entityAp.Key.EqualsIgnoreCase(barOwnerKey)) { barItem = view.GetBarItem(entityAp.Key, barItemKey); if (barItem != null) { barItem.Enabled = bEnabled; } } } }
/// <summary> /// 设置按钮可见状态 /// </summary> /// <param name="view"></param> /// <param name="barItemKey">按钮标识</param> /// <param name="bVisible">可见性</param> /// <param name="barOwnerKey">工具条拥有者标识,单据主工具条不用传值,表格工具条请传表格标识,其它独立工具条请传工具条标识</param> public static void SetBarItemVisible(this IDynamicFormView view, string barItemKey, bool bVisible, string barOwnerKey = "") { Appearance ap = null; if (!string.IsNullOrWhiteSpace(barOwnerKey)) { ap = view.LayoutInfo.GetAppearance(barOwnerKey); } BarItemControl barItem = null; if (ap == null) { barItem = view.GetMainBarItem(barItemKey); } else { barItem = view.GetBarItem(ap.Key, barItemKey); } if (barItem != null) { barItem.Visible = bVisible; } }