[CLOSED] Error on fire events on load controls

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Error on fire events on load controls

    Hi, I have updated my project from a previous version of 1.0.0 to the latest version on premium repository. After this change, I have found a general error on multiples page of my project, caused by the same problem. I explain you the detail for one of this:

    There is radio button group and a combobox. According with which one of this radio button is checked, a handler on the listener disables or not this combo.

    The problem is: the system fires the event Check for the radio button "radioGroupObligatoryAccount" before the rest of the control of the page has been loaded. So, if you debug inside on the listener Check handler, the cmbCustomerAccount is not defined yet (no control below the radio button is defined). If you remove the "Checked = "true"", the page works properly.

    Hence, it seems that after my last update, the coolite behaviour is different: before it, no listeners was fired until all the controls of the page has been loaded.

    I would need a "global" solution to it. This is only one specific page that shows this error, but there are a lot of another pages on my project with this global problem.


    Here my example detail:

    The radio button group:

    <ext:RadioGroup ID="radioGroupAccountType" runat="server" StyleSpec="padding:0px" Width="600">
    <Items>
     
    <ext:RadioColumn ID="radioColumn1" runat="server" ColumnWidth="0.25">
     
    <Items>
     
    <ext:Radio ID="radioGroupObligatoryAccount" runat="server" BoxLabel="<%$ Resources: ObligatoryAccount %>" Checked="true" >
     
    <Listeners>
     
    <Check Handler="disableAccountFields((#{radioGroupFreeAccount}.checked || #{radioGroupForbiddenAccount}.checked));" />
     
    </Listeners>
     
    <DirectEvents>
    <Check OnEvent="InitializeGridPanelCustomerCount" >
    <EventMask ShowMask="true" Msg="<%$ Resources: InitializingAccounts %>" />
     
    </Check>
     
    </DirectEvents>
     
    </ext:Radio>
     
    </Items>
     
    </ext:RadioColumn>
     
    <ext:RadioColumn ID="radioColumn2" runat="server" ColumnWidth="0.25">
     
    <Items>
     
    <ext:Radio ID="radioGroupOptionalAccount" runat="server" BoxLabel="<%$ Resources: OptionalAccount %>" >
     
    <Listeners>
     
    <Check Handler="disableAccountFields((#{radioGroupFreeAccount}.checked || #{radioGroupForbiddenAccount}.checked));" />
     
    </Listeners>
     
    <DirectEvents>
     
    <Check OnEvent="InitializeGridPanelCustomerCount" >
     
    <EventMask ShowMask="true" Msg="<%$ Resources: InitializingAccounts %>" />
     
    </Check>
     
    </DirectEvents>
     
    </ext:Radio>
     
    </Items>
     
    </ext:RadioColumn>
     
    <ext:RadioColumn ID="radioColumn3" runat="server" ColumnWidth="0.25">
     
    <Items>
     
    <ext:Radio ID="radioGroupFreeAccount" runat="server" BoxLabel="<%$ Resources: FreeAccount %>" >
     
    <Listeners>
     
    <Check Handler="disableAccountFields((#{radioGroupFreeAccount}.checked || #{radioGroupForbiddenAccount}.checked));" />
     
    </Listeners>
     
    </ext:Radio>
     
    </Items>
     
    </ext:RadioColumn>
     
    <ext:RadioColumn ID="radioColumn4" runat="server" ColumnWidth="0.25">
     
    <Items>
     
    <ext:Radio ID="radioGroupForbiddenAccount" runat="server" BoxLabel="<%$ Resources: ForbiddenAccount %>" >
     
    <Listeners>
     
    <Check Handler="disableAccountFields((#{radioGroupFreeAccount}.checked || #{radioGroupForbiddenAccount}.checked));" />
     
    </Listeners>
     
    </ext:Radio>
     
    </Items>
     
    </ext:RadioColumn>
     
    </Items>
     
    </ext:RadioGroup>
    The combo box to be disabled is:

    <ext:ComboBox ID="cmbCustomerAccount" Width="350" TriggerAction="All" runat="server" StoreID="storeCustomerAccount" ValueField="UniqueId" DisplayField="Account"
    TypeAhead="true" Mode="Local" AutoHeight="true" SelectOnFocus="true" AllowBlank="true" Editable="false" ListWidth="600"
    EmptyText="<%$ Resources: emptySelector.Text %>" ValueNotFoundText="<%$ Resources: emptySelector.Text %>" >
    </ext:ComboBox>
    And the code called by the handler is:

    var disableAccountFields = function(disabled) {
     cmbCustomerAccount.setDisabled(disabled);
    }
    And the error is: "cmbCustomerAccount is not defined"

    Thank you in advance
    Last edited by Daniil; Apr 01, 2011 at 12:36 PM. Reason: [CLOSED]
  2. #2
    Hi,

    I don't think there is a global solution to don't allow all events to fire when the page is not rendered yet.

    Also there weren't global changes in this part far a long time, since upgrading from Coolite 0.8 to Ext.Net 1.0.

    For exactly the problem that you described I could suggest you to set up the initial fields states using .Disabled property and change the function in the following way:
    var disableFields = function (disabled) {
        var combo = Ext.getCmp("ComboBox1");
        if (combo && combo.rendered) {
            combo.setDisabled(disabled);
        }
    }
  3. #3
    Hi, I attach you a simplified example. On this code, an error appears on the handler execution ("labelTest is not defined"). I consider this is a very common piece of code.

    <%@ Page Language="C#" AutoEventWireup="true" EnableViewState="false" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <html xmlns="http://www.w3.org/1999/xhtml">
     <head id="Head1" runat="server">
         <title></title>
     </head>
     <body>
         <form id="form1" runat="server">
         <ext:ResourceManager ID="ResourceManager1" runat="server" /> 
         <ext:Viewport ID="Viewport1" runat="server">
             <Content>
                 <ext:Radio ID="rbShowLabel" runat="server" Name="rbgVoucher" checked="true">
                     <Listeners>
                         <Check Handler="#{labelTest}.Hidden = false" />
                     </Listeners>
                 </ext:Radio>
                 <ext:Radio ID="rbHideLabel" runat="server" Name="rbgVoucher">
                     <Listeners>
                         <Check Handler="#{labelTest}.Hidden = true" />
                     </Listeners>
                 </ext:Radio>
                 <ext:Label runat="server" ID="labelTest" Text="You can see me" />
             </Content>
         </ext:Viewport>
         </form>
     </body>
    </html>
    Following what you've suggested, I must check all my pages and check all the events that may be executed during the page render, and then add control sentences to detect if all the controls involved have been rendered or not. This would be a huge amount of work, and I'm interesting if another chance exists. I consider this is a very common problem, not particular of my project.

    According to the version issue, then I don't understand, because the only thing I have done is updating my code to refers to your latest code version. In my previous project version (with Ext.Net 1rc (1.0.3951) ), all this problems didn't occur.

    Thank you in advance.
    Last edited by jeybonnet; Mar 21, 2011 at 9:22 AM. Reason: Format
  4. #4
    I should say that we have never checked a widget is rendered or not before firing any event.

    I mean that in the following case:
    <ext:Radio ... Checked="true">
        <Listeners>
            <Check Handler="#{someWidget}.Hidden = false" />
        </Listeners>
    </ext:Radio>
    we have never automatically checked - the "someWidget" is rendered or not.

    Well, I'm not sure what exactly thing in the new sources could change the behavior of your project.

    My one guess, that we didn't fire "check" event when Checked="true". But I'm not sure we changed this part.

    Could you provide us with the SVN Revision number that you used before update?
  5. #5
    hi,

    Ext.Net 1rc (1.0.3951)

    Quote Originally Posted by Daniil View Post
    I should say that we have never checked a widget is rendered or not before firing any event.

    I mean that in the following case:
    <ext:Radio ... Checked="true">
        <Listeners>
            <Check Handler="#{someWidget}.Hidden = false" />
        </Listeners>
    </ext:Radio>
    we have never automatically checked - the "someWidget" is rendered or not.

    Well, I'm not sure what exactly thing in the new sources could change the behavior of your project.

    My one guess, that we didn't fire "check" event when Checked="true". But I'm not sure we changed this part.

    Could you provide us with the SVN Revision number that you used before update?
  6. #6
    Do you mean that you used the official RC1 before?
  7. #7
    Daniil,

    To sum up :

    1. I run my website with Ext.net 1.0 RC which can be downloaded from Ext.net website. By checking dll version, I read : 1.0.3960 : No error
    2. I run my website with trunk Ext.net, Error



    Quote Originally Posted by Daniil View Post
    Do you mean that you used the official RC1 before?
  8. #8
    Thanks for the details.

    Yes, my guess was right.

    Previously, initial .setValue() didn't fire "check", but now it fires.

    For me, I think that the previous behavior was correct. I will consider it with Dev team.

    For now, as a workaround I can suggest you to replace
    Checked="true"
    with
    XChecked="true"
    or with
    <CustomConfig>
        <ext:ConfigItem Name="checked" Value="true" Mode="Raw" />
    </CustomConfig>
  9. #9
    As a global fix we can suggest we following script:
    Ext.form.Checkbox.prototype.initComponent = Ext.form.Checkbox.prototype.initComponent.createInterceptor(function () {
        if (this.value) {
            this.checked = this.value;
        }
    });
    You could add it into each page:
    <ext:ResourcePlaceHolder runat="server" />
    <script type="text/javascript">
        Ext.form.Checkbox.prototype.initComponent = Ext.form.Checkbox.prototype.initComponent.createInterceptor(function () {
            if (this.value) {
                this.checked = this.value;
            }
        });
    </script>
    But it would be much easier to:

    1. Add this script in the following file:
    <SVN Ext.Net root folder>\Ext.Net\Build\Ext.Net\extnet\core\form\Che ckbox.js

    2. Run
    <SVN Ext.Net root folder>\Ext.Net\Build\Ext.Net\extnet\build.bat

    3. Rebuild the Ext.Net solution
  10. #10
    Ok, thank you, I will fix my code.

    However, i'm a bit worried about it, this problem will affect to another part/controls?

    For example, I have detected the same problem executing the Load handler of a store, (if you refers to another combo not rendered yet on it).

    Thank you
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 3
    Last Post: May 03, 2012, 3:33 PM
  2. [CLOSED] Can't get State-events to fire
    By Fredrik in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: May 02, 2012, 4:44 PM
  3. Replies: 4
    Last Post: Jan 10, 2012, 10:21 AM
  4. Don't fire events
    By yyyhxm1 in forum 1.x Help
    Replies: 0
    Last Post: Jun 03, 2010, 1:18 AM
  5. Replies: 2
    Last Post: Jul 29, 2009, 1:57 PM

Tags for this Thread

Posting Permissions