I get the following javascript error when I use my code which is very similar to yours. Can you determine what I'm doing wrong?
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)
Timestamp: Thu, 10 Jun 2010 18:43:26 UTC
Message: Expected identifier, string or number
Line: 237
Char: 134
Code: 0
URI: http://localhost/wap3/extnet/extnet-core-js/ext.axd?v=30187
Imports Ext.Net
Partial Public Class ClientHoldingsGridControl
Inherits UserControl
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Ext.Net.X.IsAjaxRequest Then
BindViewBy()
End If
End Sub
Protected Function BindViewBy() As TreeGrid
grid.ActiveIndex = If(ViewBy.SelectedItem.Value.IsEmpty, 0, CInt(ViewBy.SelectedItem.Value))
Select Case grid.ActiveIndex
Case 0
Return BindViewByAccounts()
Case 1
Return BindViewByAssetType()
End Select
Return Nothing
End Function
Public Function BindViewByAccounts() As TreeGrid
Dim node As New Ext.Net.TreeNode
node.Leaf = False
node.CustomAttributes.Add(New ConfigItem("description", "test", ParameterMode.Value))
node.CustomAttributes.Add(New ConfigItem("account", "", ParameterMode.Value))
node.CustomAttributes.Add(New ConfigItem("assettype", "", ParameterMode.Value))
node.CustomAttributes.Add(New ConfigItem("marketvalue", "0", ParameterMode.Value))
node.CustomAttributes.Add(New ConfigItem("totalgainloss", "0", ParameterMode.Value))
node.CustomAttributes.Add(New ConfigItem("allocationpercent", "0", ParameterMode.Value))
node.Expanded = True
Dim root As New Ext.Net.TreeNode
root.Nodes.Add(node)
For i = 0 To 10
Dim actnode = New Ext.Net.TreeNode
actnode.Leaf = False
actnode.CustomAttributes.Add(New ConfigItem("description", "test", ParameterMode.Value))
actnode.CustomAttributes.Add(New ConfigItem("account", "test", ParameterMode.Value))
actnode.CustomAttributes.Add(New ConfigItem("assettype", "test", ParameterMode.Value))
actnode.CustomAttributes.Add(New ConfigItem("marketvalue", "0", ParameterMode.Value))
actnode.CustomAttributes.Add(New ConfigItem("totalgainloss", "0", ParameterMode.Value))
actnode.CustomAttributes.Add(New ConfigItem("allocationpercent", "0", ParameterMode.Value))
For j = 0 To 5
Dim assetnode As New Ext.Net.TreeNode
assetnode.Leaf = True
assetnode.CustomAttributes.Add(New ConfigItem("description", "test", ParameterMode.Value))
assetnode.CustomAttributes.Add(New ConfigItem("account", "", ParameterMode.Value))
assetnode.CustomAttributes.Add(New ConfigItem("assettype", "", ParameterMode.Value))
assetnode.CustomAttributes.Add(New ConfigItem("marketvalue", "0", ParameterMode.Value))
assetnode.CustomAttributes.Add(New ConfigItem("totalgainloss", "0", ParameterMode.Value))
assetnode.CustomAttributes.Add(New ConfigItem("allocationpercent", "0", ParameterMode.Value))
actnode.Nodes.Add(assetnode)
Next
node.Nodes.Add(actnode)
Next
AccountsGrid.Root.Add(root)
Return AccountsGrid
End Function
Public Function BindViewByAssetType() As TreeGrid
Dim node As New Ext.Net.TreeNode
node.Leaf = False
node.CustomAttributes.Add(New ConfigItem("description", "test", ParameterMode.Value))
node.CustomAttributes.Add(New ConfigItem("marketvalue", "0", ParameterMode.Value))
node.CustomAttributes.Add(New ConfigItem("totalgainloss", "0", ParameterMode.Value))
node.CustomAttributes.Add(New ConfigItem("allocationpercent", "0", ParameterMode.Value))
node.Expanded = True
Dim root As New Ext.Net.TreeNode
root.Nodes.Add(node)
For i = 0 To 10
Dim atnode As New Ext.Net.TreeNode
atnode.Leaf = False
atnode.CustomAttributes.Add(New ConfigItem("description", "test", ParameterMode.Value))
atnode.CustomAttributes.Add(New ConfigItem("marketvalue", "0", ParameterMode.Value))
atnode.CustomAttributes.Add(New ConfigItem("totalgainloss", "0", ParameterMode.Value))
atnode.CustomAttributes.Add(New ConfigItem("allocationpercent", "0", ParameterMode.Value))
node.Nodes.Add(atnode)
Next
AssetTypeGrid.Root.Add(root)
Return AssetTypeGrid
End Function
Public Sub ChangeGrid(ByVal sender As Object, ByVal e As DirectEventArgs)
Dim grid = BindViewBy()
grid.Call("initChildren", New JRawValue(grid.Root.ToJson()))
End Sub
End Class
<ext:FitLayout ID="FitLayout1" runat="server">
<Items>
<ext:Panel ID="grid" runat="server" Layout="Card" ActiveIndex="0" Border="false">
<TopBar>
<ext:Toolbar ID="Toolbar1" runat="server">
<Items>
<ext:ToolbarFill ID="ToolbarFill1" runat="server" />
<ext:ComboBox ID="ViewBy" runat="server" SelectedIndex="0">
<Items>
<ext:ListItem Text="Account" Value="0" />
<ext:ListItem Text="Asset Type" Value="1" />
</Items>
<DirectEvents>
<Select OnEvent="ChangeGrid" />
</DirectEvents>
</ext:ComboBox>
</Items>
</ext:Toolbar>
</TopBar>
<Items>
<ext:Panel ID="AccountsPanel" runat="server" Border="false" AutoScroll="true">
<Items>
<ext:TreeGrid ID="AccountsGrid" runat="server" AutoExpandColumn="description" Border="false">
<Columns>
<ext:TreeGridColumn Header="Decription" Width="150" DataIndex="description" />
<ext:TreeGridColumn Header="Account" Width="100" DataIndex="account" />
<ext:TreeGridColumn Header="Type" Width="150" DataIndex="assettype" />
<ext:TreeGridNumberColumn Header="Market Value" Width="125" DataIndex="marketvalue"
Align="Right" SortType="AsFloat">
<XTemplate runat="server">
<Html>
{marketvalue:usMoney}
</Html>
</XTemplate>
</ext:TreeGridNumberColumn>
<ext:TreeGridNumberColumn Header="Unrealized Gain/Loss" Width="125" DataIndex="totalgainloss"
Align="Right" SortType="AsFloat">
<XTemplate runat="server">
<Html>
{totalgainloss:usMoney}
</Html>
</XTemplate>
</ext:TreeGridNumberColumn>
<ext:TreeGridNumberColumn Header="Allocation %" Width="125" DataIndex="allocationpercent"
Align="Right" SortType="AsFloat">
<XTemplate runat="server">
<Html>
{allocationpercent} %
</Html>
</XTemplate>
</ext:TreeGridNumberColumn>
</Columns>
</ext:TreeGrid>
</Items>
</ext:Panel>
<ext:Panel ID="AssetTypePanel" runat="server" Border="false">
<Items>
<ext:TreeGrid ID="AssetTypeGrid" runat="server" AutoExpandColumn="description" Border="false">
<Columns>
<ext:TreeGridColumn Header="Description" Width="150" DataIndex="description" />
<ext:TreeGridNumberColumn Header="Market Value" Width="125" DataIndex="marketvalue"
Align="Right" SortType="AsFloat">
<XTemplate runat="server">
<Html>
{marketvalue:usMoney}
</Html>
</XTemplate>
</ext:TreeGridNumberColumn>
<ext:TreeGridNumberColumn Header="Unrealized Gain/Loss" Width="125" DataIndex="totalgainloss"
Align="Right" SortType="AsFloat">
<XTemplate runat="server">
<Html>
{totalgainloss:usMoney}
</Html>
</XTemplate>
</ext:TreeGridNumberColumn>
<ext:TreeGridNumberColumn Header="Allocation %" Width="125" DataIndex="allocationpercent"
Align="Right" SortType="AsFloat">
<XTemplate runat="server">
<Html>
{allocationpercent} %
</Html>
</XTemplate>
</ext:TreeGridNumberColumn>
</Columns>
</ext:TreeGrid>
</Items>
</ext:Panel>
</Items>
</ext:Panel>
</Items>
</ext:FitLayout>