Add default values for columns
This commit is contained in:
parent
8c8a946fea
commit
078f9724f4
@ -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,51 +603,81 @@ 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
|
||||||
|
|
||||||
AddHandler oView.CustomRowCellEdit, Sub(sender As Object, e As CustomRowCellEditEventArgs)
|
AddHandler oView.CustomRowCellEdit, Sub(sender As Object, e As CustomRowCellEditEventArgs)
|
||||||
Try
|
Try
|
||||||
For Each oRow As DataRow In DT_MY_COLUMNS.Rows
|
For Each oRow As DataRow In DT_MY_COLUMNS.Rows
|
||||||
Dim oColumnName = oRow.Item("SPALTENNAME")
|
Dim oColumnName = oRow.Item("SPALTENNAME")
|
||||||
Dim oEditorExists = GridTables_TestEditorExistsByControlAndColumn(oControlId, oColumnName)
|
Dim oEditorExists = GridTables_TestEditorExistsByControlAndColumn(oControlId, oColumnName)
|
||||||
|
|
||||||
If oColumnName = e.Column.FieldName And oEditorExists Then
|
If oColumnName = e.Column.FieldName And oEditorExists Then
|
||||||
Dim oEditor = GridTables.Item(oControlId).Item(oColumnName)
|
Dim oEditor = GridTables.Item(oControlId).Item(oColumnName)
|
||||||
|
|
||||||
e.RepositoryItem = oEditor
|
e.RepositoryItem = oEditor
|
||||||
End If
|
End If
|
||||||
Next
|
Next
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
LOGGER.Warn("Error in CustomRowCellEdit for [{0}]", e.CellValue)
|
LOGGER.Warn("Error in CustomRowCellEdit for [{0}]", e.CellValue)
|
||||||
LOGGER.Error(ex)
|
LOGGER.Error(ex)
|
||||||
End Try
|
End Try
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
AddHandler oView.ValidatingEditor, Sub(sender As Object, e As BaseContainerValidateEditorEventArgs)
|
|
||||||
Dim oRow As DataRowView = oView.GetRow(oView.FocusedRowHandle)
|
|
||||||
Dim oColumnName = oView.FocusedColumn.FieldName
|
|
||||||
|
|
||||||
GridTables_ValidateColumn(oView, DT_MY_COLUMNS, oColumnName, e.Value, e.Valid, e.ErrorText)
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
AddHandler oView.InvalidRowException, Sub(sender As Object, e As InvalidRowExceptionEventArgs)
|
|
||||||
e.ExceptionMode = ExceptionMode.NoAction
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
|
|
||||||
AddHandler oView.ValidatingEditor, Sub(sender As Object, e As BaseContainerValidateEditorEventArgs)
|
AddHandler oView.ValidatingEditor, Sub(sender As Object, e As BaseContainerValidateEditorEventArgs)
|
||||||
Dim oValue As String = NotNull(e.Value, "")
|
Dim oRow As DataRowView = oView.GetRow(oView.FocusedRowHandle)
|
||||||
|
Dim oColumnName = oView.FocusedColumn.FieldName
|
||||||
|
GridTables_ValidateColumn(oView, DT_MY_COLUMNS, oColumnName, e.Value, e.Valid, e.ErrorText)
|
||||||
|
End Sub
|
||||||
|
|
||||||
If oValue.Contains(" | ") Then
|
AddHandler oView.InvalidRowException, AddressOf View_InvalidRowException
|
||||||
oValue = oValue.Split(" | ").ToList().First()
|
AddHandler oView.ValidatingEditor, AddressOf View_ValidatingEditor
|
||||||
e.Value = oValue
|
AddHandler oView.ShowingEditor, AddressOf View_ShowingEditor
|
||||||
End If
|
AddHandler oView.ShownEditor, AddressOf View_ShownEditor
|
||||||
End Sub
|
AddHandler oView.ValidateRow, AddressOf View_ValidateRow
|
||||||
|
|
||||||
Return oControl
|
Return oControl
|
||||||
End Function
|
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
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
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, "")
|
||||||
|
|
||||||
|
If oValue.Contains(" | ") Then
|
||||||
|
oValue = oValue.Split(" | ").ToList().First()
|
||||||
|
e.Value = oValue
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Shared Sub View_InvalidRowException(sender As Object, e As InvalidRowExceptionEventArgs)
|
||||||
|
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)
|
||||||
control.Text = "------------------------------"
|
control.Text = "------------------------------"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user