Ticket Q479878
Visible to All Users

AppearanceRule for TreeList to Enable\Disable a property.

created 12 years ago

I read in the Documentation that the TreeListEditor supports conditional appearance. I have Editable TreeList which has two column.
I have add appearance rule to enable\disable a property. but it is not work for the tree list.:

[Appearance("Test", AppearanceItemType = "ViewItem", TargetItems = "Value", Enabled = false)]

Note: I have implement the TreeListInplaceEditViewController to edit in the treelist.

Answers approved by DevExpress Support

created 12 years ago (modified 10 years ago)

Since the TreeListEditor does not support in-place editing, the corresponding appearance customization is not implemented in it. To support the "Enabled" appearance for cells, create a derived list editor as follows:

C#
[ListEditor(typeof(ITreeNode), true)] public class TreeListEditorEx : TreeListEditor { public TreeListEditorEx(IModelListView model) : base(model) { } protected override void OnControlsCreated() { base.OnControlsCreated(); this.TreeList.ShowingEditor += new System.ComponentModel.CancelEventHandler(control_ShowingEditor); } void control_ShowingEditor(object sender, System.ComponentModel.CancelEventArgs e) { ObjectTreeListNode node = this.TreeList.FocusedNode as ObjectTreeListNode; if(node == null) return; CustomizeAppearanceEventArgs args = new CustomizeAppearanceEventArgs(this.TreeList.FocusedColumn.FieldName, new CancelEventArgsAppearanceAdapter(e), node.Object); this.OnCustomizeAppearance(args); } }

UPDATE:
Starting from version 12.2.11 use the following controller instead:

C#
public class TreeListAppearanceControllerEx : TreeListAppearanceController { protected override void OnTreeListChanged() { base.OnTreeListChanged(); if (base.Active && base.View != null && base.View.Editor != null && base.View.Editor is TreeListEditor && ((TreeListEditor)base.View.Editor).TreeList != null) { ((TreeListEditor)base.View.Editor).TreeList.ShowingEditor += new System.ComponentModel.CancelEventHandler(control_ShowingEditor); } } void control_ShowingEditor(object sender, System.ComponentModel.CancelEventArgs e) { TreeList tl = (TreeList)sender; ObjectTreeListNode node = tl.FocusedNode as ObjectTreeListNode; if (node == null) return; this.OnCustomizeAppearance(new CustomizeAppearanceEventArgs(tl.FocusedColumn.FieldName, "ViewItem", new GridViewCancelEventArgsAppearanceAdapter(null, e), node.Object)); } }

UPDATE:
Starting from version 14.2, another CustomizeAppearanceEventArgs shoudl be used:

C#
this.OnCustomizeAppearance(new CustomizeAppearanceEventArgs(tl.FocusedColumn.FieldName, "ViewItem", new GridViewCancelEventArgsAppearanceAdapter(null, e), node.Object, null));
    Comments (2)

      When I implement this solution I got an error exception:
      An error with number 1120 has occurred.
      Error: Cannot find the 'AppearanceDisableValuePropertyWhenItIsReadOnly' member within the 'System.Collections.ArrayList' class
      I have this:
      [Appearance("AppearanceDisableValuePropertyWhenItIsReadOnly", AppearanceItemType = "ViewItem", TargetItems = "Value", Enabled = false)] public bool AppearanceDisableValuePropertyWhenItIsReadOnly() { return IsReadOnly ; }
      I have also tried to make the method AppearanceDisableValuePropertyWhenItIsReadOnly static
      but I got always the error exception.

      DevExpress Support Team 12 years ago

        I have updated my answer. I apologize for the mistake.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.