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

Page 1 of 2 12 LastLast
  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
  7. #7
    yes, something must have changed... but I cant see what. The code posted does look correct and it was the same thing that was working only 40 minutes ago.

    I guess I will have to redo the whole page again =(
  8. #8
    So I added a dummy GridPanel to the page and references that instead in the ExtraParameters.

    That worked fine - no "undefined" there. Then I changed the name of the dummy GridPanel and referenced it wrong in the <ext:Parameter...> just to see how it reacts. Instead of getting "undefined" I get:

    Uncaught TypeError: Cannot call method 'getRowsValues' of null
    So its a difference here. Why?

    If I again change it back so it has the right name in <ext:Parameter...> but I dont use the #{...} then I get the "undefined" message.

    I have tried to change the names of the real gridpanels, but taht didnt work...
  9. #9
    So, the GridPanel that I cannot reference (theres actually two of them) is placed inside a DropDown, like this:

    <ext:Panel ID="Panel16" runat="server" AutoWidth="true" Height="30" Border="false" Layout="Form">
        <Items>
            <ext:DropDownField ID="DropDownField2" runat="server" Editable="false" FieldLabel="test" AnchorHorizontal="100%">
                <Component>
                         // GridPanel here!                               
                </Component>
            </ext:DropDownField>
        </Items>
    </ext:Panel>
    When I move the GridPanel out of the DropDown, then I can reference it. So instead of the DropDown above I just place the GridPanel directly. Then it can be referenced and I get the e.Parameters OK in the DirectEvent on the server.

    Why is that?
  10. #10
    I have actually managed to make a runnable example of it.

    It does not matter if I use #{...} in the DirectEvent. The code as below till give a "undefined" error, but if you just cut-paste the GridPanel so that it is placed OUTSIDE of the DropDown the error is gone.

    Any ideas? Please note that it has worked to have the GridPanel inside the DropDown, but stopped working "all of a sudden". Dont see why.

    Take a look:

    <%@ 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="Head1" runat="server">
        <title>Ext.Net Example</title>
     
        <script runat="server">
            public void CreateBooking(object sender, DirectEventArgs e)
            {      // Break here
                   
            }
        </script>
    </head>
    <body>
        <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        
        <ext:DropDownField ID="DropDownField2" runat="server" Editable="false" FieldLabel="test" AnchorHorizontal="100%">
            <Component>
                    <ext:GridPanel runat="server" ID="GridPanel_Equipment" 
                    Height="150" 
                    AutoExpandColumn="EquipmentName" 
                    >
                    <Store>
    	                <ext:Store runat="server" ID="Store_Equipment">
    	                <Reader>
    		                <ext:ArrayReader>
    		                <Fields>
    			                <ext:RecordField Name="EquipmentId"></ext:RecordField>
    			                <ext:RecordField Name="EquipmentName"></ext:RecordField>
    			                <ext:RecordField Name="EquipmentNbr"></ext:RecordField>
    		                </Fields>
    		                </ext:ArrayReader>
    	                </Reader>
    	                </ext:Store>
                    </Store>
                    <Plugins>
    	                <ext:EditableGrid ID="EditableGrid1" runat="server" />
                    </Plugins>
                    <ColumnModel ID="ColumnModel4" runat="server">
    	                <Columns>
    	                <ext:Column ColumnID="EquipmentId" DataIndex="EquipmentId" Hidden="true" />
    	                <ext:Column Header="Namn" DataIndex="EquipmentName" />
    	                <ext:Column Header="Antal" DataIndex="EquipmentNbr" Width="20">
    		                <Editor>
    		                <ext:NumberField ID="NumberField1" runat="server" Width="20"></ext:NumberField>
    		                </Editor>
    	                </ext:Column>
    	                </Columns>
                    </ColumnModel>
                    <LoadMask ShowMask="true" />
                    <SelectionModel>
    	                <ext:RowSelectionModel ID="RowSelectionModel2" runat="server" />
                    </SelectionModel>
                    <View>
    	                <ext:GroupingView  
    	                ID="GroupingView2"
    	                HideGroupedColumn="true"
    	                StartCollapsed="true"
    	                runat="server" 
    	                ForceFit="true"
    	                />
                    </View>            
                </ext:GridPanel>
            </Component>
        </ext:DropDownField>
    
    
        <ext:Button ID="Button1" runat="server" Text="test" FieldLabel="test" Icon="ArrowRight">
            <DirectEvents>
                <Click OnEvent="CreateBooking">
                    <ExtraParams>
                        <ext:Parameter
                            Name="asd"
                            Value="GridPanel_Equipment.getRowsValues()"
                            Mode="Raw"
                            Encode="true" />
                    </ExtraParams>
                </Click>
            </DirectEvents>
        </ext:Button>
        </form>
    </body>
    </html>
Page 1 of 2 12 LastLast

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