According to various information I have found here and a couple of other locations, flexigrid requires the XML to have specific format:
rows - the row definition
page - the current page number
total - the total count of rows in this collection
row - the row, with a unique property called id
cell - each row must contain cells in the order that they are displayed on the grid
Since the MyDataClass was generated as a result of your previous question, here are updated versions of those classes that will produce the desired output:
<XmlType("rows")> _
Public Class MyDataClass
<XmlElement("page")> _
Public Property Page As Integer
<XmlElement("total")> _
Public ReadOnly Property Total As Integer
Get
If Me.Rows IsNot Nothing Then
Return Me.Rows.Count
Else
Return 0
End If
End Get
End Property
<XmlElement("row")> _
Public Property Rows As List(Of MyDataRow)
' Parameterless constructor to support serialization.
Public Sub New()
Me.Rows = New List(Of MyDataRow)
End Sub
Public Sub New(wPage As Integer, ds As DataSet)
Me.New()
Me.Page = wPage
For Each oRow As DataRow In ds.Tables(0).Rows
Dim oMyRow As New MyDataRow
oMyRow.Id = CInt(oRow("id"))
oMyRow.Name = CStr(oRow("Name"))
Me.Rows.Add(oMyRow)
Next
End Sub
End Class
<XmlType("row")> _
Public Class MyDataRow
<XmlAttribute("id")> _
Public Property Id As Integer
Private m_cCells As List(Of MyDataCell)
<XmlIgnore()> _
Public WriteOnly Property Name As String
Set(value As String)
Me.AddCell("Name", value)
End Set
End Property
<XmlElement("cell")> _
Public ReadOnly Property Cells As List(Of MyDataCell)
Get
Return m_cCells
End Get
End Property
' Parameterless constructor to support serialization
Public Sub New()
m_cCells = New List(Of MyDataCell)
End Sub
Public Sub AddCell(sCellName As String, sCellValue As String)
m_cCells.Add(New MyDataCell(sCellName, sCellValue))
End Sub
End Class
Public Class MyDataCell
<XmlIgnore()> _
Public Property Name As String
<XmlText()> _
Public Property Value As String
' Parameterless constructor to support serialization
Public Sub New()
End Sub
Public Sub New(sCellName As String, sCellValue As String)
Me.New()
Me.Name = sCellName
Me.Value = sCellValue
End Sub
End Class