Add default values for columns

This commit is contained in:
Jonathan Jenne 2021-10-11 16:31:18 +02:00
parent 8c8a946fea
commit 078f9724f4

View File

@ -52,6 +52,7 @@ Public Class ClassControlCreator
''' Saves the column data for each grid and each column in that grid ''' Saves the column data for each grid and each column in that grid
''' </summary> ''' </summary>
Public Shared Property GridTables As New Dictionary(Of Integer, Dictionary(Of String, RepositoryItem)) Public Shared Property GridTables As New Dictionary(Of Integer, Dictionary(Of String, RepositoryItem))
Public Shared Property GridColumns As New Dictionary(Of Integer, DataTable)
''' <summary> ''' <summary>
''' Standard Eigenschaften für alle Controls ''' Standard Eigenschaften für alle Controls
@ -478,6 +479,12 @@ Public Class ClassControlCreator
End With End With
If GridColumns.ContainsKey(oControlId) Then
GridColumns.Item(oControlId) = DT_MY_COLUMNS
Else
GridColumns.Add(oControlId, DT_MY_COLUMNS)
End If
If GridTables.ContainsKey(oControlId) Then If GridTables.ContainsKey(oControlId) Then
GridTables.Item(oControlId).Clear() GridTables.Item(oControlId).Clear()
Else Else
@ -578,7 +585,7 @@ Public Class ClassControlCreator
AddHandler oView.InitNewRow, Sub(sender As Object, e As InitNewRowEventArgs) AddHandler oView.InitNewRow, Sub(sender As Object, e As InitNewRowEventArgs)
' TODO: Remove when this works and is properly implemented. ' TODO: Remove when this works and is properly implemented.
Exit Sub 'Exit Sub
Try Try
For Each oColumnData As DataRow In DT_MY_COLUMNS.Rows For Each oColumnData As DataRow In DT_MY_COLUMNS.Rows
@ -596,6 +603,8 @@ Public Class ClassControlCreator
Next Next
Catch ex As Exception Catch ex As Exception
LOGGER.Error(ex) LOGGER.Error(ex)
Finally
newRowModified = False
End Try End Try
End Sub End Sub
@ -617,19 +626,46 @@ Public Class ClassControlCreator
End Try End Try
End Sub End Sub
AddHandler oView.ValidatingEditor, Sub(sender As Object, e As BaseContainerValidateEditorEventArgs) AddHandler oView.ValidatingEditor, Sub(sender As Object, e As BaseContainerValidateEditorEventArgs)
Dim oRow As DataRowView = oView.GetRow(oView.FocusedRowHandle) Dim oRow As DataRowView = oView.GetRow(oView.FocusedRowHandle)
Dim oColumnName = oView.FocusedColumn.FieldName Dim oColumnName = oView.FocusedColumn.FieldName
GridTables_ValidateColumn(oView, DT_MY_COLUMNS, oColumnName, e.Value, e.Valid, e.ErrorText) GridTables_ValidateColumn(oView, DT_MY_COLUMNS, oColumnName, e.Value, e.Valid, e.ErrorText)
End Sub End Sub
AddHandler oView.InvalidRowException, Sub(sender As Object, e As InvalidRowExceptionEventArgs) AddHandler oView.InvalidRowException, AddressOf View_InvalidRowException
e.ExceptionMode = ExceptionMode.NoAction AddHandler oView.ValidatingEditor, AddressOf View_ValidatingEditor
AddHandler oView.ShowingEditor, AddressOf View_ShowingEditor
AddHandler oView.ShownEditor, AddressOf View_ShownEditor
AddHandler oView.ValidateRow, AddressOf View_ValidateRow
Return oControl
End Function
Private Shared Sub View_ValidateRow(sender As Object, e As ValidateRowEventArgs)
Dim view As GridView = TryCast(sender, GridView)
If view.IsNewItemRow(e.RowHandle) AndAlso Not newRowModified Then view.DeleteRow(e.RowHandle)
newRowModified = False
End Sub End Sub
Private Shared Sub View_ShownEditor(sender As Object, e As EventArgs)
Dim view As GridView = TryCast(sender, GridView)
If view.IsNewItemRow(view.FocusedRowHandle) Then
AddHandler view.ActiveEditor.Modified, Sub() newRowModified = True
End If
End Sub
AddHandler oView.ValidatingEditor, Sub(sender As Object, e As BaseContainerValidateEditorEventArgs) Private Shared newRowModified As Boolean
Private Shared Sub View_ShowingEditor(sender As Object, e As CancelEventArgs)
Dim view As GridView = TryCast(sender, GridView)
If view.IsNewItemRow(view.FocusedRowHandle) AndAlso Not newRowModified Then
view.AddNewRow()
End If
End Sub
Private Shared Sub View_ValidatingEditor(sender As Object, e As BaseContainerValidateEditorEventArgs)
Dim oValue As String = NotNull(e.Value, "") Dim oValue As String = NotNull(e.Value, "")
If oValue.Contains(" | ") Then If oValue.Contains(" | ") Then
@ -638,8 +674,9 @@ Public Class ClassControlCreator
End If End If
End Sub End Sub
Return oControl Private Shared Sub View_InvalidRowException(sender As Object, e As InvalidRowExceptionEventArgs)
End Function e.ExceptionMode = ExceptionMode.NoAction
End Sub
Public Shared Function CreateExistingLine(row As DataRow, designMode As Boolean) As LineLabel Public Shared Function CreateExistingLine(row As DataRow, designMode As Boolean) As LineLabel
Dim control As LineLabel = CreateBaseControl(New LineLabel(), row, designMode) Dim control As LineLabel = CreateBaseControl(New LineLabel(), row, designMode)