This repository has been archived by the owner on Oct 16, 2023. It is now read-only.
/
TreeListInlineEditController.vb
52 lines (50 loc) · 2.84 KB
/
TreeListInlineEditController.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Imports System
Imports DevExpress.ExpressApp
Imports System.Web.UI.WebControls
Imports DevExpress.ExpressApp.Web
Imports DevExpress.Web.ASPxTreeList
Imports DevExpress.ExpressApp.Web.Editors
Imports DevExpress.Persistent.Base.General
Imports DevExpress.ExpressApp.Web.Editors.ASPx
Imports DevExpress.ExpressApp.TreeListEditors.Web
Namespace WebExample.Module.Web
Public Class TreeListInlineEditController
Inherits ViewController(Of ListView)
Public Sub New()
TargetObjectType = GetType(ITreeNode)
End Sub
Protected Overrides Sub OnViewControlsCreated()
MyBase.OnViewControlsCreated()
Dim editor As ASPxTreeListEditor = TryCast(View.Editor, ASPxTreeListEditor)
If editor IsNot Nothing AndAlso View.Model.AllowEdit Then
editor.TreeList.SettingsEditing.Mode = DevExpress.Web.ASPxTreeList.TreeListEditMode.Inline
AddHandler editor.TreeList.NodeUpdating, AddressOf TreeList_NodeUpdating
AddHandler editor.TreeList.CommandColumnButtonInitialize, AddressOf TreeList_CommandColumnButtonInitialize
For Each column As TreeListColumn In editor.TreeList.Columns
If TypeOf column Is TreeListDataColumn AndAlso CType(column, TreeListDataColumn).EditCellTemplate IsNot Nothing Then
Dim propertyEditor As WebPropertyEditor = CType(CType(column, TreeListDataColumn).EditCellTemplate, EditModeDataItemTemplate).PropertyEditor
AddHandler propertyEditor.ControlCreated, AddressOf propertyEditor_ControlCreated
End If
Next column
End If
End Sub
Private Sub TreeList_NodeUpdating(ByVal sender As Object, ByVal e As DevExpress.Web.Data.ASPxDataUpdatingEventArgs)
ObjectSpace.CommitChanges()
End Sub
Private Sub TreeList_CommandColumnButtonInitialize(ByVal sender As Object, ByVal e As TreeListCommandColumnButtonEventArgs)
If e.ButtonType = TreeListCommandColumnButtonType.Edit Then
e.Visible = DevExpress.Utils.DefaultBoolean.True
e.CommandColumn.ButtonType = ButtonType.Link
e.CommandColumn.EditButton.Text = "Inline Edit"
ElseIf e.ButtonType = TreeListCommandColumnButtonType.Update OrElse e.ButtonType = TreeListCommandColumnButtonType.Cancel Then
e.Visible = DevExpress.Utils.DefaultBoolean.True
End If
End Sub
Private Sub propertyEditor_ControlCreated(ByVal sender As Object, ByVal e As EventArgs)
Dim control As WebControl = TryCast(DirectCast(sender, WebPropertyEditor).Editor, WebControl)
If control IsNot Nothing Then
control.Attributes("onclick") = RenderHelper.EventCancelBubbleCommand
End If
End Sub
End Class
End Namespace