[CLOSED] Problems once again with referencing Controls : GridPanel "undefined"?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] Problems once again with referencing Controls : GridPanel "undefined"?

    Hey,
    so once again I get the dreaded "MyFineControl is not defined".

    So, I have a button, that button has a a DirectEvent, and that directEvent has Parametes as can be seen here:

    <ext:Button ID="btnCreate" Icon="Disk" Text="Save" runat="server" >
        <DirectEvents>
            <Click OnEvent="Create">
                <ExtraParams>
                    <ext:Parameter
                        Name="GridPanel_Customer"
                        Value="GridPanel_Customer.getRowsValues()"
                        Mode="Raw"
                        Encode="true" />
                </ExtraParams>
            </Click>
        </DirectEvents>
    </ext:Button>
    The gridpanel that is referenced in the above DirectEvent is here (same page):

    <ext:GridPanel runat="server"  ID="GridPanel_Customer"
        Height="150" 
        AutoExpandColumn="CustomerName">
        <Store>
            <ext:Store runat="server" ID="Store_Customer">
                <Reader>
                    <ext:ArrayReader>
                        <Fields>
                            <ext:RecordField Name="CustomerTypeId"></ext:RecordField>
                            <ext:RecordField Name="CustomerName"></ext:RecordField>
                            <ext:RecordField Name="CustomerNbr"></ext:RecordField>
                        </Fields>
                    </ext:ArrayReader>
                </Reader>
            </ext:Store>
        </Store>
        // etc
    </ext:GridPanel>
    The question is: why do I get "undefined" when referencing the GridPanel?

    There is no other gridpanel on the page that has that name.

    Note:
    I cannot use the #{....} things because then at server-side when I look in e.Parameters, the name of the parameter is a whole lot more than "GridPanel_Customer" and since I dont have that other name, I cannot just do

    string jsonValues = e.ExtraParams["GridPanel_Customer"];
    since that will give me NullRef because the name is something else. Therefore I cannot use IDMode="Explicit" either as I understand it.

    Now, I have looked at this example:
    http://forums.ext.net/showthread.php...ore+jsonValues

    and in that example, Daniil does not use #{...} or IDMode="Explicit".

    Does it work because the Button is defined AFTER the GridPanel in Daniils example? In my code the Button and DirectEvent is defined before the GridPanel.
    Last edited by Daniil; Apr 15, 2011 at 12:07 PM. Reason: [CLOSED]
  2. #2
    Actually, I solved it by not being stupid, ie the Name didnt have to have #{GridPanel_Customer} since its just text, so after removing that it can be access on server-side.

    I forgot to mention in my previous post that I am working inside a UserControl. Is that why I need to use the #{...} thing?

    ??

    <ext:Button ID="btnCreate" Icon="Disk" Text="Save" runat="server" >
        <DirectEvents>
            <Click OnEvent="CreateU">
                <ExtraParams>
                    <ext:Parameter
                        Name="GridPanel_Customer"
                        Value="#{GridPanel_Customer}.getRowsValues()"
                        Mode="Raw"
                        Encode="true" />
                </ExtraParams>
            </Click>
        </DirectEvents>
    </ext:Button>
  3. #3
    Hi,

    MasterPage, ContentPlaceHolder or UserControl (frankly, it are all user control inheritors) implements INamingContainer interface. In this case, ASP.Net generates Client doesn't equal ID. In the client side we use ClientID only therefore you cannot use ID for referencing controls in javascript code
    In simple cases (if there is no INamingContainer) ClientID equals ID
    So, #{} syntax is recommended or use IDMode="Explicit" (to ensure ID == ClientID)
  4. #4
    Thanks!

    It worked for a while. However, now it stopped working. Undefined again, even when using #{...}

    I tried ti make a sample so I could post here, but in that scaled-down version the error does not show. But in the main app it does!

    I didnt change anything that I know if. The code is the same as post #1 but "undefined" shows up now... Very weird.
  5. #5
    Im curious on how to look for why it all of a sudden stopped working?

    If I have these irritating reference error - where do I start to look for solutions?

    I am checking out the source code on the web page right now to see if the ClientIDs are there.

    As I can see it, ClientIDs are the same. Here is som ugle source code:

    editable:false,component:{store:this.Store_Equipme nt=new Ext.ux.data.PagingStore({proxyId:"Store_Equipment" ,autoLoad:true,reader:new Ext.data.ArrayReader({fields:[{name:"EquipmentId"},{name:"EquipmentName"},{name: "EquipmentNbr"}]}),directEventConfig:{},proxy:new Ext.data.PagingMemoryProxy({})}),id:"GridPanel_Equipment123",xtype:"netgrid",plugins:this.E

    and a little bit further down...

    directEvents:{click:{fn:function(item,e){var params=arguments;Ext.net.DirectEvent.confirmReques t({extraParams:{"GridPanel_Equipment":Ext.encode(GridPanel_Equipment123.getRowsValues())

    And my code is this:

        
    <ext:Button ID="Button1" runat="server" Text="Skicka" FieldLabel="test" Icon="ArrowRight">
       <DirectEvents>
            <Click OnEvent="CreateBooking">
                <ExtraParams>
                    <ext:Parameter
                        Name="GridPanel_Equipment"
                        Value="GridPanel_Equipment123.getRowsValues()"
                        Mode="Raw"
                        Encode="true" />
                    <ext:Parameter
                        Name="GridPanel_CustomerCompanions"
                        Value="#{GridPanel_CustomerCompanions123}.getRowsValues()"
                        Mode="Raw"
                        Encode="true" />
                </ExtraParams>
            </Click>
        </DirectEvents>
    </ext:Button>
    and the two GridPanels in questioin (I get undefined for both)

    <ext:GridPanel runat="server" ID="GridPanel_Equipment123" IDMode="Explicit"
        Height="150" 
        AutoExpandColumn="EquipmentName" 
        >
        // etc...
    and

    <ext:GridPanel runat="server"  ID="GridPanel_CustomerCompanions123"
        Height="150" 
        AutoExpandColumn="CustomerCompanionTypeName" 
        Frame="true">
  6. #6
    Hi wagger,

    The code you posted appears to be correct. You say nothing changed, although I suspect something has.
    Geoffrey McGill
    Founder

Similar Threads

  1. [CLOSED] Problems when usin "Content" instead of "Items"
    By Pablo_Azevedo in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 24, 2012, 1:43 PM
  2. Replies: 4
    Last Post: Oct 11, 2011, 2:42 AM
  3. [CLOSED] GridPanel / Renderer : Property "undefined"?
    By wagger in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: May 03, 2011, 8:50 PM
  4. Replies: 9
    Last Post: Apr 25, 2011, 8:23 PM
  5. Replies: 12
    Last Post: Apr 13, 2011, 3:28 PM

Tags for this Thread

Posting Permissions