Can I access ext:hidden element from javascript

  1. #1

    Can I access ext:hidden element from javascript



    Hi all,

    How could I access the Ext:Hidden value from javascript? I am trying to show/hide rows according to the rowcount value that is updated during the Page_Load. Ext.getCmp('rowCount') does not help me. or is this a purely my design problem that I have to use Ext components for the table? I try to keep things simple.

    Provided a simplified version of the code as below. Thanks in advance.

    
    <%@ Page Language="C#" %>
    
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" 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>Test</title>
    <script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
    // read number of records from db
    // update rowCount, rowCount.Text ="2";
    // populate records    
    
    
    }
    </script>
    
    
    <script type="text/javascript">
    
    
        function DisplayRow(rowID) {
            var x = &#100;ocument.getElementById(rowID);
            x.style.display = '';
        }
    </script>
    </head>
    <body>
    <form id="form1" runat="server">
    <ext:ScriptManager ID="ScriptManager1" runat="server"/>
    <ext:Panel ID="QualiPanel" runat="server" Title="Group1" AutoHeight="true">
        <Body >
            <ext:Hidden ID="rowCount" runat="server" Text="1" />    
            <table>
                <tr id="row1" style="display:none">
                    <td>
                    <p>ROW1:</p>
                    <ext:TextField ID="txtField1" runat="server" Width="180" />
                    </td>
                    <td >
                    <p> Date:</p>
                    <ext:TextField ID="txtField2" runat="server" Width="60"/>
                    </td>
                </tr>
                <tr id="row2" style="display:none">
                    <td style="width:52%;">
                    <p>ROW2:</p>
                    <ext:TextField ID="txtField3" runat="server" Width="180" />
                    </td>
                    <td style="width:48%;" >
                    <p>Award Date:</p>
                    <ext:TextField ID="txtField4" runat="server" Width="60"/>
                    </td>
                </tr>
            </table>
    </body>
    </ext:Panel>
    </form>
    
    
    <script type="text/javascript">
       // Ext.getCmp('rowCount'); does not do the job
       // if row count is 1, it will not show row2.
       //  eg DisplayRow('row1');
    
    </script>
    </body>
    </html>
  2. #2

    RE: Can I access ext:hidden element from javascript

    it would be:

    hdnFieldNameHere.getValue();
    and

    hdnFieldNameHere.setValue('Value here');
  3. #3

    RE: Can I access ext:hidden element from javascript

    I'll add...

    *All* Field type controls can be set/get client-side using the .getValue() and .setValue(value) functions.


    http://extjs.com/deploy/dev/docs/?cl...ember=getValue


    Geoffrey McGill
    Founder
  4. #4

    RE: Can I access ext:hidden element from javascript

    I tried

    alert(rowCount.getValue());

    at the end of the code.

    but I got JScript runtime error. rowCount is undefined. I missed anything?
  5. #5

    RE: Can I access ext:hidden element from javascript

    Hi,

    Because you execute that code until hidden field is created. Try to wrap it with Ext.onReady(function(){your code})
  6. #6

    RE: Can I access ext:hidden element from javascript

    Thanks Vladimir for your quick response. It works now. Really appreciate it.

Similar Threads

  1. [2.0 Beta 2] nCannot access Hidden field
    By Alexx in forum 2.x Help
    Replies: 2
    Last Post: May 03, 2012, 9:31 AM
  2. Replies: 12
    Last Post: Jul 26, 2011, 9:43 AM
  3. Get Coolite Element with Javascript
    By apenunuri in forum 1.x Help
    Replies: 3
    Last Post: Jun 30, 2010, 5:35 PM
  4. Replies: 2
    Last Post: Jun 24, 2010, 7:58 PM
  5. Replies: 8
    Last Post: Jun 11, 2008, 9:58 AM

Posting Permissions