事件在没有任何声明的情况下被触发

时间:2021-09-19 03:19:44

First of all, let me present to you the exception I get in the screen.

首先,让我向你们展示我在屏幕上得到的异常。

The control 'Store1' does not have an DirectEvent with the name 'DataChanged' or the handler is absent 

I have some pages in my project, when I go under the page "A" and change to the page "B" and then hit backspace ( so I go to the last page I was ), I get that error. But if I go to the page "B" and change back to "A", I get no error.

在我的项目中,我有一些页面,当我在“A”页面下切换到“B”页面,然后点击backspace(因此我转到最后一页I是),我得到了这个错误。但是如果我转到B页,再转到A页,就不会出错。

I noticed that when the error occurs, a column I added is not there, and since the bind to the ext.Store happens when the page is not postback, I can't watch the value that has been through.

我注意到,当发生错误时,我添加的列不在那里,并且由于绑定到ext.Store发生在页面非回发时,我无法查看已通过的值。

Now, this is the grid that holds the ext.Store :

这是保存ext.Store的网格:

<ext:GridPanel id="GridPanel1" idmode="Explicit" runat="server" autoheight="true"
        title="Solicitações" autoexpandcolumn="Descricao">
        <Store>
            <ext:Store ID="Store1" runat="server" GroupField="solCodigo" GroupOnSort="true">
                <Reader>
                    <ext:JsonReader IDProperty="solCodigo">
                        <Fields>
                            <ext:RecordField Name="solCodigo" SortDir="DESC" />
                            <ext:RecordField Name="solDescricao" Type="String" />
                            <ext:RecordField Name="solStatus" Type="String" />
                            <ext:RecordField Name="proDescricao" Type="String" />
                            <ext:RecordField Name="solDataSolicitacao" Type="Date" />
                            <ext:RecordField Name="solDataPrevista" Type="Date" />
                            <ext:RecordField Name="solNumArquivos" />
                            <ext:RecordField Name="funNomeSolucionador" Type="String" />
                            <ext:RecordField Name="solPrioridade" />
                            <ext:RecordField Name="solDataSolucao" Type="String" />
                        </Fields>
                    </ext:JsonReader>
                </Reader>
            </ext:Store>
        </Store>
        <View>
            <%--
            <ext:GroupingView runat="server" HideGroupedColumn="true" EmptyGroupText="Indefinido" ID="groupingView1" EnableGrouping="false" EnableGroupingMenu="false">
                <GetRowClass Fn="getRowClass" />
            </ext:GroupingView>--%>
        </View>
        <ColumnModel runat="server">
            <Columns>
                <ext:Column DataIndex="solCodigo" Header="Código" Width="40">
                </ext:Column>
                <ext:Column ColumnID="Descricao" Header="Descrição" DataIndex="solDescricao">
                    <Renderer Format="Ellipsis" FormatArgs="50" />
                    <Commands>
                        <ext:ImageCommand CommandName="Comando" />
                    </Commands>
                    <PrepareCommand Fn="prepareCellCommand" />
                </ext:Column>
                <ext:DateColumn Header="Solicitado em" DataIndex="solDataSolicitacao">
                </ext:DateColumn>
                <ext:DateColumn Header="Data prevista" DataIndex="solDataPrevista">
                </ext:DateColumn>
                <ext:Column ColumnID="Projeto" Header="Projeto" DataIndex="proDescricao">
                </ext:Column>
                <ext:Column Header="Situação" DataIndex="solStatus">
                    <Renderer Fn="situacaoRender" />
                </ext:Column>
                <ext:Column Header="Data de Solução" DataIndex="solDataSolucao">
                </ext:Column>
                <ext:Column Header="Prioridade" DataIndex="solPrioridade">
                    <Renderer Fn="prioridadeRender" />
                </ext:Column>
            </Columns>
        </ColumnModel>
        <DirectEvents>
            <DblClick OnEvent="GridPanel1_DblClick" Before="if(#{GridPanel1}.getSelectionModel().getSelected() == undefined) return false; ">
                <EventMask ShowMask="true" />
                <ExtraParams>
                    <%-- or can use params[2].id as value --%>
                    <%-- <ext:Parameter Name="id" Value="#{GridPanel1}.getSelectionModel().getSelected().id;"
                        Mode="Raw" />--%>
                    <ext:Parameter Name="Values" Value="Ext.encode(#{GridPanel1}.getRowsValues({selectedOnly:true}))"
                        Mode="Raw" />
                </ExtraParams>
            </DblClick>
        </DirectEvents>
        <Plugins>
            <%--  <ext:RowExpander ID="RowExpander1" runat="server" >
                <Template ID="Template1" runat="server">
                    <Html>
                        <p><b>Detalhes:</b> {solDescricao}</p>
                        <p><b>Arquivos:</b> {solNumArquivos}</p>
                    </Html>
                </Template>
            </ext:RowExpander>--%>
        </Plugins>
        <SelectionModel>
            <ext:RowSelectionModel runat="server" SingleSelect="true" />
        </SelectionModel>
    </ext:GridPanel>

And how it bound

以及它如何绑定

 DataTable dtSol = new DataTable();
                dtSol = sol.Listar();
                DataTable dtResult = new DataTable();
                dtResult.Columns.Add("solCodigo", typeof(int));
                dtResult.Columns.Add("solDescricao", typeof(string));
                dtResult.Columns.Add("solDataSolicitacao", typeof(DateTime));
                dtResult.Columns.Add("solDataPrevista", typeof(DateTime));
                dtResult.Columns.Add("proDescricao", typeof(string));
                dtResult.Columns.Add("solStatus", typeof(string));
                dtResult.Columns.Add("solPrioridade", typeof(int));
                dtResult.Columns.Add("solDataSolucao", typeof(string));

                var result = from r in dtSol.AsEnumerable()
                             select dtResult.LoadDataRow(new object[] 
                             {
                                 r.Field<int>("solCodigo"),
                                 r.Field<string>("solDescricao"),
                                 r.Field<DateTime>("solDataSolicitacao"),
                                 r.Field<DateTime>("solDataPrevista"),
                                 r.Field<string>("proDescricao"),
                                 r.Field<string>("solStatus"),
                                 r.Field<int>("solPrioridade"),
                                 r.Field<DateTime>("solDataSolucao") > DateTime.Now.AddMinutes(1) ? string.Empty : r.Field<DateTime>("solDataSolucao").ToString("dd/MM/yyyy")
                             }, false);

                this.Store1.DataSource = result.ToList().Any() ? dtResult : new DataTable();

                this.Store1.DataBind();

Thanks in advance.

提前谢谢。

EDIT User Request

编辑用户请求

protected void GridPanel1_DblClick(object sender, DirectEventArgs e)
        {
            //string ID = e.ExtraParams["id"];
            string json = e.ExtraParams["Values"];

            json = json.Replace("solNumArquivos\":\"\"", "solNumArquivos\":0");

            clSolicitacao sol = JSON.Deserialize<List<clSolicitacao>>(json).First();
            if (sol.solStatus == "DF")
            {
                Response.Redirect("Chamado.aspx?codigo=" + sol.solCodigo);
            }
            else
            {
                Response.Redirect("ExibirChamado.aspx?codigo=" + sol.solCodigo);
            }


        }

EDIT 2

编辑2

Ext.onReady(function(){Ext.QuickTips.init();Ext.apply(Ext.net.DirectMethods, { EfetuaLogout:function(blnLogout,config){Ext.net.DirectMethod.request("EfetuaLogout",Ext.applyIf(config || {}, {params:{blnLogout:blnLogout}}));} });new Ext.net.LinkButton({id:"menuBuscar",labelAlign:"top",renderTo:"menuBuscar_Container",width:50,arrowAlign:"bottom",iconAlign:"top",iconCls:"icon-magnifier",menu:{id:"ctl00",xtype:"menu",width:140,items:[{id:"ctl01",xtype:"menutextitem",text:"Código:"},{id:"txtBusca",xtype:"textfield",autoCreate:{"tag":"input","type":"text","maxlength":7,"autocomplete":"off"},maxLength:7,directEvents:{specialkey:{fn:function(el,e){var params=arguments;Ext.net.DirectEvent.confirmRequest({formProxyArg:"Form1",eventMask:{showMask:true,msg:"Buscando solicitações..."},before:function(el, type, action, extraParams){return e.getKey() == Ext.EventObject.ENTER;},control:this,action:'SpecialKey'});},delay:20}}},{id:"ctl02",iconCls:"icon-magnifier",text:"Buscar",directEvents:{click:{fn:function(el,e){var params=arguments;Ext.net.DirectEvent.confirmRequest({formProxyArg:"Form1",eventMask:{showMask:true,msg:"Buscando solicitações..."},control:this});},delay:20}}}]},text:"Buscar solicitação"});new Ext.net.GridPanel({store:this.Store1=new Ext.ux.data.PagingStore({proxyId:"Store1",autoLoad:true,reader:new Ext.data.JsonReader({fields:[{name:"solCodigo",sortDir:"DESC"},{name:"solDescricao",type:"string"},{name:"solStatus",type:"string"},{name:"proDescricao",type:"string"},{name:"solDataSolicitacao",type:"date",dateFormat:"Y-m-dTh:i:s"},{name:"solDataPrevista",type:"date",dateFormat:"Y-m-dTh:i:s"},{name:"solNumArquivos"},{name:"funNomeSolucionador",type:"string"},{name:"solPrioridade"}],idProperty:"solCodigo"}),directEventConfig:{formProxyArg:"Form1"},groupField:"solCodigo",groupOnSort:true,proxy:new Ext.data.PagingMemoryProxy([{"solCodigo":2213,"solDataSolicitacao":"2013-04-16T11:16:23","solDataPrevista":"2013-04-17T11:16:23","solPrioridade":3,"solDescricao":"Gostaria de ter acesso a base dbCOEServiceDesk do servidor BRSPTP09.\r\n\r\nO motivo do pedido &#233; para poder aplicar testes e implementar o pr&#243;prio sistema do ServiceDesk assim como foi relatado nas pend&#234;ncias relatadas pelo Silva, Paulo Roberto da.\r\n\r\nO usu&#225;rio para qual o acesso &#233; solicitado &#233; &quot; aseixas &quot;. O mesmo do solicitante deste chamado.\r\n\r\nGrato.","solStatus":"SP","proDescricao":"CrCt(Petrobrás) - SP","funNomeSolucionador":"DANIELA BRITO COSTA                               ","solNumArquivos":0},{"solCodigo":2214,"solDataSolicitacao":"2013-05-10T15:33:11","solDataPrevista":"2013-05-11T15:33:11","solPrioridade":3,"solDescricao":"sdfgdf","solStatus":"SF","proDescricao":"Consiste","funNomeSolucionador":"ANDRE SILVA DE SEIXAS                             ","solNumArquivos":0},{"solCodigo":2215,"solDataSolicitacao":"2013-05-13T13:43:34","solDataPrevista":"2013-05-14T13:43:34","solPrioridade":3,"solDescricao":"abc","solStatus":"SP","proDescricao":null,"funNomeSolucionador":null,"solNumArquivos":0},{"solCodigo":2216,"solDataSolicitacao":"2013-05-13T13:45:06","solDataPrevista":"2013-05-14T13:45:06","solPrioridade":3,"solDescricao":"abc","solStatus":"SP","proDescricao":null,"funNomeSolucionador":null,"solNumArquivos":0},{"solCodigo":2217,"solDataSolicitacao":"2013-05-13T13:47:01","solDataPrevista":"2013-05-14T13:47:01","solPrioridade":3,"solDescricao":"abc","solStatus":"SP","proDescricao":null,"funNomeSolucionador":null,"solNumArquivos":0},{"solCodigo":2218,"solDataSolicitacao":"2013-05-13T13:52:43","solDataPrevista":"2013-05-14T13:52:43","solPrioridade":3,"solDescricao":"asdf","solStatus":"SP","proDescricao":"Connector","funNomeSolucionador":null,"solNumArquivos":0},{"solCodigo":2219,"solDataSolicitacao":"2013-05-13T13:56:17","solDataPrevista":"2013-05-14T13:56:17","solPrioridade":3,"solDescricao":"asd","solStatus":"SP","proDescricao":"Connector","funNomeSolucionador":null,"solNumArquivos":0}], false),directEvents:{datachanged:{fn:function(store){var params=arguments;Ext.net.DirectEvent.confirmRequest({formProxyArg:"Form1",control:this,action:'DataChanged'});},delay:20}}}),id:"GridPanel1",renderTo:"GridPanel1_Container",autoHeight:true,title:"Solicitações",autoExpandColumn:"Descricao",sm:this.ContentPlaceHolder1_ctl00=new Ext.grid.RowSelectionModel({proxyId:"",singleSelect:true}),selectionMemory:false,cm:this.ContentPlaceHolder1_ctl01=new Ext.grid.ColumnModel({proxyId:"",defaultSortable:true,columns:[{dataIndex:"solCodigo",header:"Código",width:40},{dataIndex:"solDescricao",header:"Descrição",id:"Descricao",renderer:function(value){return Ext.util.Format.ellipsis(value,50);},commands:[{command:"Comando"}],isCellCommand:true,prepareCommand:prepareCellCommand},{dataIndex:"solDataSolicitacao",header:"Solicitado em",xtype:"datecolumn",format:"d/m/Y"},{dataIndex:"solDataPrevista",header:"Data prevista",xtype:"datecolumn",format:"d/m/Y"},{dataIndex:"proDescricao",header:"Projeto",id:"Projeto"},{dataIndex:"solStatus",header:"Situação",renderer:situacaoRender},{dataIndex:"solPrioridade",header:"Prioridade",renderer:prioridadeRender}]}),directEvents:{dblclick:{fn:function(e){var params=arguments;Ext.net.DirectEvent.confirmRequest({formProxyArg:"Form1",extraParams:{Values:Ext.encode(GridPanel1.getRowsValues({selectedOnly:true}))},eventMask:{showMask:true},before:function(el, type, action, extraParams){if(GridPanel1.getSelectionModel().getSelected() == undefined) return false; },control:this,action:'DblClick'});},delay:20}}});new Ext.Window({id:"wndChromeWarning",hidden:true,renderTo:Ext.get("Form1"),height:220,width:400,closable:false,buttons:[{id:"ctl03",xtype:"button",text:"Fechar aviso",listeners:{click:{fn:function(el,e){wndChromeWarning.hide()}}}}],header:false,padding:25,contentEl:"wndChromeWarning_Content",modal:true});});Ext.net.ResourceMgr.init({id:"ctl00$ResourceManager1",BLANK_IMAGE_URL:"/extjs/resources/images/gray/s-gif/ext.axd",aspForm:"Form1"});

2 个解决方案

#1


1  

This one is a bit tricky, but I suspect that when you are going back to page 'A', the program is trying to locate a handler for a DataChanged event. Total shot in the dark... maybe try adding said event to the DirectEvents element.

这个有点棘手,但我怀疑当您返回到“a”页时,程序正在尝试为一个DataChanged事件定位一个处理程序。完全在黑暗中拍摄……也许可以尝试将这个事件添加到DirectEvents元素中。

Note: I am posting this as an answer at the OP's request. It was orginally in the comments.

注意:这是我在OP的要求下发布的答案。这是在评论中。

#2


1  

I can guess that you add (somewhere?) DataChanged direct event handler in the code behind and don't readd that handler during next requests

我猜你(在什么地方?)在后面的代码中,DataChanged直接事件处理程序,并在下次请求时不读取该处理程序。

That exception occurs if resource manager detects that a request is direct event request and the widget has no attached handlers for the event

如果资源管理器检测到一个请求是直接事件请求,并且小部件没有附加的事件处理程序,则会发生此异常

Can you post generated javascript code for the problem page?

是否可以为问题页面发布生成的javascript代码?

#1


1  

This one is a bit tricky, but I suspect that when you are going back to page 'A', the program is trying to locate a handler for a DataChanged event. Total shot in the dark... maybe try adding said event to the DirectEvents element.

这个有点棘手,但我怀疑当您返回到“a”页时,程序正在尝试为一个DataChanged事件定位一个处理程序。完全在黑暗中拍摄……也许可以尝试将这个事件添加到DirectEvents元素中。

Note: I am posting this as an answer at the OP's request. It was orginally in the comments.

注意:这是我在OP的要求下发布的答案。这是在评论中。

#2


1  

I can guess that you add (somewhere?) DataChanged direct event handler in the code behind and don't readd that handler during next requests

我猜你(在什么地方?)在后面的代码中,DataChanged直接事件处理程序,并在下次请求时不读取该处理程序。

That exception occurs if resource manager detects that a request is direct event request and the widget has no attached handlers for the event

如果资源管理器检测到一个请求是直接事件请求,并且小部件没有附加的事件处理程序,则会发生此异常

Can you post generated javascript code for the problem page?

是否可以为问题页面发布生成的javascript代码?