我正在开发一个 ASP.NET 网站,并且正在使用带有 RowExpander 部分的 GridPanel。:
<ext:RowExpander ID="RowExpander1" runat="server">
<Loader ID="Loader1" runat="server" DirectMethod="#{DirectMethods}.GetGrid" Mode="Component">
<LoadMask ShowMask="true" />
<Params>
<ext:Parameter Name="id" Value="this.record.getId()" Mode="Raw" />
</Params>
</Loader>
</ext:RowExpander>
在代码隐藏中,名为“GetData”的函数必须动态创建嵌套的 GridPanel,如下所示:
<Ext.Net.DirectMethod()>
Public Function GetGrid(ByVal parameters As Dictionary(Of String, String)) As Object
Dim data As New List(Of Object)
For i = 1 To 10
data.Add(New With {.ID = "P" & i, .Name = "Product " & i})
Next
Dim config As New Ext.Net.GridPanel.Config
config.Height = 50
config.EnableColumnHide = False
config.StoreID = "Store2"
Dim store As New Ext.Net.Store
Dim model As New Ext.Net.Model
store.ID = "Store2"
store.DataSource = data
store.ModelName = "Model2"
model.ID = "Model2"
model.IDProperty = "ID"
model.Fields.Add("ID")
model.Fields.Add("Name")
store.Model.Add(model)
config.Store.Add(store)
config.StoreID = "Store2"
Dim column As New Ext.Net.Column
column.ID = "ColumnModel2"
column.Text = "Products's Name"
column.DataIndex = "Name"
config.ColumnModel.Columns.Add(column)
config.ColumnModel.Add(column)
Dim grid As New Ext.Net.GridPanel(config)
Return Ext.Net.ComponentLoader.ToConfig(grid)
End Function
当我单击 GridPanel 中的“+”时,它显示一个空网格,即使没有列。其实Ext.Net.ComponentLoader.ToConfig(grid)生成的代码是:
[{"height":50,"xtype":"grid","columns":{},"enableColumnHide":false,"store":"Store2"}]
所以我在 GetGrid 函数中做错了什么。我错过了什么?
我遇到的每个示例都是用 C# 编写的。