Hi there,
installed ES2012 V2, I have a gridgroupinggrid (GGC) that I try to bind to businessObjects.
Mapping and filling TableDescriptor is done via iterating through ObjectProperties
__________
Private Sub InitializeGrid()
Dim computerPropertyType As Type = GetType(IMyObject)
Dim assetPropertyType As Type = GetType(IBaseClass)
Dim computerItemProperty As PropertyInfo
Dim allCol As GridColumnDescriptorCollection = New GridColumnDescriptorCollection()
Dim singlecol As GridColumnDescriptor
'IBaseClass:
For Each computerItemProperty In assetPropertyType.GetProperties()
singlecol = New GridColumnDescriptor(computerItemProperty.Name, computerItemProperty.Name, computerItemProperty.Name)
singlecol.AllowFilter = True
If singlecol.Name <> "" Then
allCol.Add(singlecol)
End If
Next
'IMyObject Class:
For Each computerItemProperty In computerPropertyType.GetProperties()
singlecol = New GridColumnDescriptor(computerItemProperty.Name, computerItemProperty.Name, computerItemProperty.Name)
singlecol.AllowFilter = True
allCol.Add(singlecol)
Next
'Enable Filtering
m_Filter.WireGrid(GGC)
GGC.TableDescriptor.Columns.Clear()
GGC.TableDescriptor.Columns = allCol
End Sub
__________
After intialization, next steps were to get the data and bind them to datasource:
' MyObjectCollection inherits only Ilist(of MyObject)
Dim myObjects as MyObjectCollection = GetObjectCollection()
GGC.Datasource = myObjects
--> This fails, as when binding occurs the debugger runs into the dataset - cast -exception as some data are null. The businesObject itself, declared in an Interface, handles this by returning string.empty or nothing. I have no idea why the binding-process runs down to the dataset.
Then I simply used the collection and built a new list:
Dim myObjects as MyObjectCollection = GetObjectCollection()
Dim myDataSource = list(of MyObject) = new List(of MyObject)
For each mysimpleObject as MyObject in MyObjectCollection
myDatasource.Add(mysimpleObject)
next
GGC.Datasource = myDatasource
This works, EXCEPT! That there are data which are not shown.
The Class MyObject inherits from a BaseClass (e.g. field "id"), and these items are not shown in the grid.
Class MyObject
Inherits BaseClass
MyName as string
MyDate as Date
...
All direct fields (MyName,MyDate) are shown correctly, the derived fields are not shown at all; the columns itself are appearing, the cellvalues are missing.
Perhaps I could solve it when I get the key to setup the datasource for the collection. Can someone provide me an example?
I found the reason. Which is, btw, not reasonable!
The Class "MyObject" should encapsulate the access to the dataset, but there was a public property DataRow of Type DataSetRow.
Changing this property to "Private", and the grid collects the data with no error and shows the inherited elements also.
I guess the Syncfusion-Grid tries something in reflection and runs there into the dataset when the property is public, and if private it uses the object-declaration...
So, now I can setup the Datasource to "MyObjectCollection" and everything works fine...