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
|
||||
''' </summary>
|
||||
Public Shared Property GridTables As New Dictionary(Of Integer, Dictionary(Of String, RepositoryItem))
|
||||
Public Shared Property GridColumns As New Dictionary(Of Integer, DataTable)
|
||||
|
||||
''' <summary>
|
||||
''' Standard Eigenschaften für alle Controls
|
||||
@ -478,6 +479,12 @@ Public Class ClassControlCreator
|
||||
|
||||
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
|
||||
GridTables.Item(oControlId).Clear()
|
||||
Else
|
||||
@ -578,7 +585,7 @@ Public Class ClassControlCreator
|
||||
|
||||
AddHandler oView.InitNewRow, Sub(sender As Object, e As InitNewRowEventArgs)
|
||||
' TODO: Remove when this works and is properly implemented.
|
||||
Exit Sub
|
||||
'Exit Sub
|
||||
|
||||
Try
|
||||
For Each oColumnData As DataRow In DT_MY_COLUMNS.Rows
|
||||
@ -596,51 +603,81 @@ Public Class ClassControlCreator
|
||||
Next
|
||||
Catch ex As Exception
|
||||
LOGGER.Error(ex)
|
||||
Finally
|
||||
newRowModified = False
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
AddHandler oView.CustomRowCellEdit, Sub(sender As Object, e As CustomRowCellEditEventArgs)
|
||||
Try
|
||||
For Each oRow As DataRow In DT_MY_COLUMNS.Rows
|
||||
Dim oColumnName = oRow.Item("SPALTENNAME")
|
||||
Dim oEditorExists = GridTables_TestEditorExistsByControlAndColumn(oControlId, oColumnName)
|
||||
Try
|
||||
For Each oRow As DataRow In DT_MY_COLUMNS.Rows
|
||||
Dim oColumnName = oRow.Item("SPALTENNAME")
|
||||
Dim oEditorExists = GridTables_TestEditorExistsByControlAndColumn(oControlId, oColumnName)
|
||||
|
||||
If oColumnName = e.Column.FieldName And oEditorExists Then
|
||||
Dim oEditor = GridTables.Item(oControlId).Item(oColumnName)
|
||||
If oColumnName = e.Column.FieldName And oEditorExists Then
|
||||
Dim oEditor = GridTables.Item(oControlId).Item(oColumnName)
|
||||
|
||||
e.RepositoryItem = oEditor
|
||||
End If
|
||||
Next
|
||||
Catch ex As Exception
|
||||
LOGGER.Warn("Error in CustomRowCellEdit for [{0}]", e.CellValue)
|
||||
LOGGER.Error(ex)
|
||||
End Try
|
||||
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
|
||||
e.RepositoryItem = oEditor
|
||||
End If
|
||||
Next
|
||||
Catch ex As Exception
|
||||
LOGGER.Warn("Error in CustomRowCellEdit for [{0}]", e.CellValue)
|
||||
LOGGER.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
|
||||
AddHandler oView.ValidatingEditor, Sub(sender As Object, e As BaseContainerValidateEditorEventArgs)
|
||||
Dim oValue As String = NotNull(e.Value, "")
|
||||
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
|
||||
|
||||
If oValue.Contains(" | ") Then
|
||||
oValue = oValue.Split(" | ").ToList().First()
|
||||
e.Value = oValue
|
||||
End If
|
||||
End Sub
|
||||
AddHandler oView.InvalidRowException, AddressOf View_InvalidRowException
|
||||
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
|
||||
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
|
||||
|
||||
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
|
||||
Dim control As LineLabel = CreateBaseControl(New LineLabel(), row, designMode)
|
||||
control.Text = "------------------------------"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user