[CLOSED] Error in GridPanel.Listeners.CellDblClick to trigger the fireevent('click') method in button in parent window.

  1. #1

    [CLOSED] Error in GridPanel.Listeners.CellDblClick to trigger the fireevent('click') method in button in parent window.

    Hi!

    1 - My main page create and show a window (in code behind).
    2 - In window is loaded a page with a gridPanel.
    3 - When 'OK' button is clicked, I trigger this javascript, calling the directmethod in MainPage.. Its works.
    "parent.App.direct.ShowRecordSelected(Ext.encode(" & wnd.ClientID & ".getBody().App.gridPanel1.getRowsValues({selectedOnly:true})));" & wnd.ClientID & ".close();"
    4 -When cell double click in gridPanel, in page loaded in window, I triggered a click event in button of window... In this step, I got a error.
    Runtime Error in Microsoft JScript: 'Ext' is undefined.

    Attachment 3971

    Follow the sample project:

    Main page
    <%@ Page Language="vb" %>
    <%@ 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">
    
    <script runat="server">
        
        Protected Sub AddWindow(sender As Object, evt As Ext.Net.DirectEventArgs)
            Dim wnd As Ext.Net.Window
            wnd = getWindow()
            Me.Form.Controls.Add(wnd)
            wnd.Render()
            wnd.Show()
        End Sub
        
        Protected Function getWindow(Optional url As String = "~/test43.aspx", Optional pTitle As String = "test", Optional iconUrl As String = "") As Ext.Net.Window
            Dim wnd As New Ext.Net.Window
            Dim loader As New Ext.Net.ComponentLoader
            Dim btn As Ext.Net.Button
            
            loader.Url = url
            loader.Mode = Ext.Net.LoadMode.Frame
            loader.LoadMask.ShowMask = True
            loader.LoadMask.Msg = "Carregando..."
    
            wnd.ID = "window_" & (New System.Random).Next(Integer.MaxValue).ToString
            wnd.Title = pTitle
            If iconUrl <> "" Then
            Else
                wnd.Icon = Ext.Net.Icon.ApplicationForm
            End If
            wnd.AutoRender = False
            wnd.Collapsible = False
            wnd.Hidden = True
            wnd.AutoRender = False
            wnd.Maximizable = False
            wnd.Loader = loader
            wnd.CloseAction = CloseAction.Destroy
            wnd.Width = 420
            wnd.Height = 270
            
            btn = New Ext.Net.Button
            btn.ID = "btnOK_" & wnd.ID
            btn.Text = "Ok"
            btn.TextAlign = ButtonTextAlign.Center
            btn.Icon = Icon.Accept
    
            btn.Listeners.Click.Handler = "parent.App.direct.ShowRecordSelected(Ext.encode(" & wnd.ClientID & ".getBody().App.gridPanel1.getRowsValues({selectedOnly:true})));" & wnd.ClientID & ".close();"
            
            wnd.Buttons.Add(btn)
            
            btn = New Ext.Net.Button
            btn.ID = "btnCancel_" & wnd.ID
            btn.Text = "Cancel"
            btn.TextAlign = ButtonTextAlign.Center
            btn.Icon = Icon.Cancel
            btn.Listeners.Click.Handler = wnd.ClientID & ".close();"
            wnd.Buttons.Add(btn)
            
            Return wnd
    
        End Function
        
        <DirectMethod()>
        Public Sub ShowRecordSelected(records As Newtonsoft.Json.Linq.JArray)
            Dim record As Newtonsoft.Json.Linq.JToken
            record = records(0)
            Ext.Net.X.Msg.Alert("Record selected: " + record("ID").ToString, "ID: " & record("ID").ToString & "</br>" & "Name:" & record("Name").ToString).Show()
        End Sub
        
        <DirectMethod()>
        Public Sub ShowWindow()
            Dim wnd As Ext.Net.Window
            wnd = getWindow("~/test25.aspx")
            Me.Form.Controls.Add(wnd)
            wnd.Render()
            wnd.Show()
        End Sub
        
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <ext:ResourceManager ID="resManagerDividas" runat="server" Locale="pt-BR" />
        <form id="form1" runat="server">
        <ext:Button runat="server" ID="btnCreateWindow" Text="Create and Show Window" OnDirectClick="addWindow" />
        </form>
    </body>
    </html>
    Page with gridPanel
    <%@ Page Language="vb" %>
    <%@ 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">
    
    <script runat="server" >
         
        ''ESTES COMANDOS SÃO PERTENCENTES AO GRID E AO STORE, E ESTÃO AQUI PARA ATUALIZAR O MESMO COM A NOVA ESTRUTURA
        Protected Sub Page_Load(sender As Object, E As EventArgs) Handles Me.Load
            
            If (Not ExtNet.IsAjaxRequest) Then
        
                BindSet()
                
            End If
            
        End Sub
        
        Private Function getDataTable() As System.Data.DataTable
            Dim table As System.Data.DataTable = New System.Data.DataTable
            
            table.Columns.Add(New System.Data.DataColumn("ID"))
            table.Columns.Add(New System.Data.DataColumn("Name"))
            
            table.Rows.Add(1, "Anderson Silva")
            table.Rows.Add(2, "José Aldo")
            table.Rows.Add(3, "Vitor Belfort")
            table.Rows.Add(4, "Lyoto Machida")
            table.Rows.Add(5, "Maurício Shogun Rua")
                    
            Return table
            
        End Function
        
        Private Sub BindSet()
    
            Me.Store1.DataSource = Me.getDataTable()
            Me.Store1.DataBind()
    
        End Sub
    
        Private Sub AddField(field As ModelField)
            If (ExtNet.IsAjaxRequest) Then
                Me.Store1.AddField(field)
            Else
                Me.Store1.Model(0).Fields.Add(field)
            End If
        End Sub
        
        Protected Sub store_Refresh(sender As Object, e As StoreRefreshDataEventArgs)
            BindSet()
        End Sub
            
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <ext:ResourceManager ID="resManagerDividas" runat="server" Locale="pt-BR" />
        <form id="form1" runat="server">
        <ext:Viewport runat="server" ID="vwpRequisicoes">
            <Items>
                <ext:GridPanel runat="server" ID="gridPanel1" Height="200" Width="400" >
                    <Store>
                        <ext:Store runat="server" ID="Store1" OnReadData="store_Refresh" IgnoreExtraFields="false" PageSize="10" RemoteSort="true" >
                            <Model>
                                <ext:Model ID="modelExplorerWebContext" runat="server" IDProperty="ID">
                                    <Fields>
                                        <ext:ModelField Name="ID" Type="Int"/>
                                        <ext:ModelField Name="Name" />
                                    </Fields>
                                </ext:Model>
                            </Model>
                        </ext:Store>
                    </Store>
                    <ColumnModel>
                        <Columns>
                            <ext:Column runat="server" ID="cID" DataIndex="ID" Text="ID" Width="60" />
                            <ext:Column runat="server" ID="cName" DataIndex="Name" Text="Name" Width="250" />
                        </Columns>
                    </ColumnModel>
                    <SelectionModel>
                        <ext:RowSelectionModel runat="server" ID="rsmExplorerWebContext" Mode="Single"/>
                    </SelectionModel>
                    <Listeners>
                        <CellDblClick Handler="parent.Ext.getCmp('btnOK_' + parentAutoLoadControl.id).fireEvent('click');" />
                    </Listeners>
                    <BottomBar>
                        <ext:PagingToolbar ID="tbPaging1" runat="server" />
                    </BottomBar>
                </ext:GridPanel>
            </Items>
        </ext:Viewport>
        </form>
    </body>
    </html>
    Last edited by Daniil; Mar 21, 2012 at 11:18 AM. Reason: [CLOSED]
  2. #2
    Hi,

    Generally, this is the same error as here:
    http://forums.ext.net/showthread.php...ll=1#post76800
    which is solved with a small delay.

    So, please set up:
    btn.Listeners.Click.Delay = 1
    for the
    btn.ID = "btnOK_" & wnd.ID
    button.
  3. #3
    works fine!

    Thanks a lot, Daniil!

Similar Threads

  1. Replies: 7
    Last Post: Feb 09, 2012, 11:17 AM
  2. [CLOSED] Button event is not firing in parent window from popup window
    By rnachman in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 14, 2011, 7:35 PM
  3. Replies: 4
    Last Post: Sep 17, 2010, 10:33 PM
  4. Replies: 2
    Last Post: Sep 09, 2010, 8:25 PM
  5. Q: Button Listeners.Click Question
    By bruce in forum 1.x Help
    Replies: 1
    Last Post: Mar 17, 2009, 2:31 AM

Posting Permissions