[CLOSED] Javascript error when using this usercontrol

Page 2 of 3 FirstFirst 123 LastLast
  1. #11

    RE: [CLOSED] Javascript error when using this usercontrol

    Do you have any idea when there will be some documentation? I feel like I'm struggling to understand everything.
  2. #12

    RE: [CLOSED] Javascript error when using this usercontrol

    For the example that you linked to, how do I pass the tree that corresponds to what's selected in the combobox?
  3. #13

    RE: [CLOSED] Javascript error when using this usercontrol

    Hi,

    I did not understand requirement from last post. Please provide more details.
    Selected value of the combo is available during DirectEvent, just generate required nodes depend from that value
    If you still have a problem with refreshing nodes during direct event then I can make a sample for you, just please provide a requirements for such sample
  4. #14

    RE: [CLOSED] Javascript error when using this usercontrol

    The example you linked to shows how to update a tree when a button is clicked. I need to adapt this to update the tree when a combobox value is selected and the refresh function will have to be passed the tree corresponding to the combobox value.
  5. #15

    RE: [CLOSED] Javascript error when using this usercontrol

    Maybe I should clarify what I'm trying to do...

    I want to have a combobox that when a value is selected, a treegrid based on that value will display and nodes will be added. If another value is selected from the combobox, a different treegrid will be displayed and nodes will be added to it. Only one of the treegrids should be visible at a time and correspond to what's selected in the combobox.
  6. #16

    RE: [CLOSED] Javascript error when using this usercontrol

    Hi,

    Here is example which refreshes the nodes in the TreeGrid
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head2" runat="server">
        <title>TreeGrid - Ext.NET Examples</title>
        
        <script runat="server">
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!X.IsAjaxRequest)
                {
                    this.TreeGrid1.Root.Add(this.GetNodes(null));
                }
            }
    
            protected void ChangeTreeGridSet(object sender, DirectEventArgs e)
            {
                this.TreeGrid1.Root.Add(this.GetNodes(this.Combo1.SelectedItem));
                this.TreeGrid1.Call("initChildren", new JRawValue(this.TreeGrid1.Root.ToJson()));
            }
            
            private Ext.Net.TreeNode GetNodes(Ext.Net.ListItem selectedItem)
            {
                Ext.Net.TreeNode root = new Ext.Net.TreeNode("root");
                
                if(selectedItem == null)
                {
                    selectedItem = Combo1.Items[0];
                }
    
                for (int i = 1; i <= 10; i++)
                {
                    Ext.Net.TreeNode node = new Ext.Net.TreeNode
                    {
                        CustomAttributes =
                        {
                            new ConfigItem("combo", "Combo: " + selectedItem.Text, ParameterMode.Value),
                            new ConfigItem("index", i.ToString())
                        }
                    };
    
                    root.Nodes.Add(node);
                }
    
                return root;
            }
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <ext:ComboBox ID="Combo1" runat="server" SelectedIndex="0">
                <Items>
                    <ext:ListItem Text="Set 1" Value="1" />
                    <ext:ListItem Text="Set 2" Value="2" />
                    <ext:ListItem Text="Set 3" Value="3" />
                </Items>
                <DirectEvents>
                    <Select OnEvent="ChangeTreeGridSet" />
                </DirectEvents>
            </ext:ComboBox>
            
            <ext:TreeGrid 
                ID="TreeGrid1"
                runat="server"
                Title="TreeGrid"
                Width="500"
                Height="300"
                NoLeafIcon="true"
                EnableDD="true">
                <Columns>
                    <ext:TreeGridColumn Header="Combo Value" Width="240" DataIndex="combo" />
                    
                    <ext:TreeGridColumn Header="Index" Width="240" DataIndex="index" />
                </Columns>
            </ext:TreeGrid>        
        </form>
    </body>
    </html>
  7. #17

    RE: [CLOSED] Javascript error when using this usercontrol

    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>
  8. #18

    RE: [CLOSED] Javascript error when using this usercontrol

    Hi,

    Define any text for the root node
    new Ext.Net.TreeNode("root")
  9. #19

    RE: [CLOSED] Javascript error when using this usercontrol

    It works on the initial page load. It's only when I switch it via the combobox.
  10. #20

    RE: [CLOSED] Javascript error when using this usercontrol

    Hi,

    I didn't understand your issue. Please provide more details about what you expects from that sample and what you have
Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. Replies: 0
    Last Post: Mar 29, 2011, 3:59 PM
  2. Replies: 2
    Last Post: Jan 14, 2011, 5:51 PM
  3. [CLOSED] [1.0] Javascript error when loading usercontrol from code
    By klaus.schwarz in forum 1.x Legacy Premium Help
    Replies: 17
    Last Post: Jul 12, 2010, 3:59 PM
  4. [CLOSED] Javascript Error loading dynamic usercontrol 1.0
    By SymSure in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Apr 01, 2010, 3:05 AM
  5. How to add UserControl in JavaScript?
    By dbassett74 in forum 1.x Help
    Replies: 2
    Last Post: May 27, 2009, 8:52 PM

Posting Permissions