This example shows how to implement a custom ViewController that gets access to the TreeList control and makes it editable according to the XtraTreeList documentation:
WinForms Controls > Controls > Tree List > Feature Center > Data Editing
TreeListOptionsBehavior.Editable Property
TreeList.ShowingEditor Event
TreeList.CellValueChanged Event
Take special note that special handling is required for the correct operation of editors for reference properties (e.g., a lookup filtering functionality requires obtaining the currently selected record).
This is not a complete solution and you will need to modify and test this example code further in other scenarios according to your business requirements. For instance, if you require supporting ConditionalAppearance rules, consider using the code from the Q479878 ticket. If you require supporting member-level security permissions, consider extending this example by analogy with the DevExpress.ExpressApp.Win.SystemModule.GridListEditorMemberLevelSecurityController class for GridListEditor.
See also:
How to enable in-place editing in the ASP.NET tree List View (ASPxTreeListEditor)
Tree List Editors - How to edit data directly in the tree view (inplace / inline modifications)
Question Comments
Added By: Kerry Busby at: 6/21/2012 10:17:49 PM
Are there any plans on ever incorporating this into the 'official' code base of XAF. The solution below previously could be manipulated with another controller to support EditorStateRule attributes and disable specific property editors however not that the EditorState module has been removed in DXPerience 2012 this is not possible or at least a LOT more difficult with the new Appearance module. There are a number of posts requesting this previously but currently it appears as if TreeLists with inplaced editing will never be 'officially' supported.
Added By: Willem de Vries at: 12/7/2012 3:11:17 AM+1 for Kerry!
DX, do not hesitate to upgrade Xpand gems to the XAF code base.
Willem
A nice addition to this example is support for ImmediatePostDataAttribute:
[code lang="cs"]
void treeList_CellValueChanging(object sender, CellValueChangedEventArgs e)
{
if (ImmediatePostData(e))
{
SetValue(e);
}
}
private void treeList_CellValueChanged(object sender, CellValueChangedEventArgs e)
{
if (!ImmediatePostData(e))
{
SetValue(e);
}
}
private void SetValue(CellValueChangedEventArgs e)
{
object newValue = e.Value;
if (e.Value is IXPSimpleObject)
newValue = ObjectSpace.GetObject(e.Value);
object focusedObject = _treeList.FocusedObject;
if (focusedObject != null)
{
IMemberInfo focusedColumnMemberInfo = ObjectSpace.TypesInfo.FindTypeInfo(focusedObject.GetType()).FindMember(e.Column.FieldName);
if (focusedColumnMemberInfo != null)
focusedColumnMemberInfo.SetValue(focusedObject, Convert.ChangeType(newValue, focusedColumnMemberInfo.MemberType));
}
}
private bool ImmediatePostData(CellValueChangedEventArgs e)
{
if (_treeList.FocusedObject != null)
{
IMemberInfo focusedColumnMemberInfo = ObjectSpace.TypesInfo.FindTypeInfo(_treeList.FocusedObject.GetType()).FindMember(e.Column.FieldName);
return focusedColumnMemberInfo.FindAttribute<DevExpress.Persistent.Base.ImmediatePostDataAttribute>() != null;
}
return false;
}
[/code]