85 lines
2.5 KiB
VB.net
85 lines
2.5 KiB
VB.net
Imports DevExpress.XtraGrid
|
|
Imports DevExpress.XtraGrid.Views.Grid
|
|
Imports DigitalData.GUIs.Common
|
|
Imports DigitalData.Modules.Logging
|
|
Imports MultiTool.Shared
|
|
|
|
Public Class GridLoader
|
|
Inherits BaseClass
|
|
|
|
Public Sub New(pLogConfig As LogConfig)
|
|
MyBase.New(pLogConfig, pLogConfig.GetLogger())
|
|
End Sub
|
|
|
|
Public Function GetGridFromElement(pGrid As GridControl, pTable As Schemas.Schema.Table) As GridControl
|
|
Dim oInvisibleColumns As New List(Of String) From {
|
|
"BELEGKEY",
|
|
"Zeilennummer",
|
|
"Belegart",
|
|
"Infotext",
|
|
"Leistungsdatum",
|
|
"Projektnummer",
|
|
"Auftragsreferenz",
|
|
"Laufnummer"
|
|
}
|
|
|
|
pGrid.Name = pTable.Name
|
|
pGrid.ForceInitialize()
|
|
pGrid.MainView.PopulateColumns()
|
|
|
|
Dim oView As GridView = pGrid.DefaultView
|
|
oView.OptionsBehavior.ReadOnly = True
|
|
oView.OptionsBehavior.Editable = False
|
|
|
|
For Each oCol In pTable.Columns
|
|
Dim oVisibleIndex As Integer = 0
|
|
|
|
' Hide certain columns
|
|
If oInvisibleColumns.Contains(oCol.Name) Then
|
|
oVisibleIndex = -1
|
|
End If
|
|
|
|
Dim oColumn = New Columns.GridColumn With {
|
|
.Name = oCol.Name,
|
|
.Caption = oCol.Name,
|
|
.FieldName = oCol.Name,
|
|
.UnboundType = GetColumnType(oCol),
|
|
.VisibleIndex = oVisibleIndex
|
|
}
|
|
|
|
oView.Columns.Add(oColumn)
|
|
|
|
Next
|
|
|
|
oView.BestFitColumns()
|
|
|
|
Dim oGridBuilder As New GridBuilder(oView)
|
|
oGridBuilder.
|
|
WithDefaults().
|
|
WithReadOnlyOptions().
|
|
WithClipboardHandler()
|
|
|
|
Return pGrid
|
|
End Function
|
|
|
|
Private Function GetColumnType(pColumn As Schemas.Schema.Column)
|
|
Select Case pColumn.DataType
|
|
Case MultiTool.Shared.Constants.ColumnType.Boolean
|
|
Return DevExpress.Data.UnboundColumnType.Boolean
|
|
|
|
Case MultiTool.Shared.Constants.ColumnType.Date
|
|
Return DevExpress.Data.UnboundColumnType.DateTime
|
|
|
|
Case MultiTool.Shared.Constants.ColumnType.Integer
|
|
Return DevExpress.Data.UnboundColumnType.Integer
|
|
|
|
Case MultiTool.Shared.Constants.ColumnType.Decimal
|
|
Return DevExpress.Data.UnboundColumnType.Decimal
|
|
|
|
Case Else
|
|
Return DevExpress.Data.UnboundColumnType.String
|
|
End Select
|
|
|
|
End Function
|
|
End Class
|