[CLOSED] Dynamically set field label in javascript

  1. #1

    [CLOSED] Dynamically set field label in javascript

    Hello,

    I´ve read in the ExtJS boards, that it´s not easy to set a field label dynamically.
    Does anybody have a good solution for that?


    My problem...

    I have a grid and a window. When I click on a grid cell,
    then my window opens to edit the selected row in that grid.

    I´m doing it like that:

     var openInputWindow = function (record) {
            currentRecord = record;
            var window = <%= Inputwindow.ClientID %>;
         
         
           if(record.data['PRICE']!=null)
      {
            <%=LblPrice.ClientID %>.setTitle(record.data['PRICE']);
      }
      else
      {
            <%=LblPrice.ClientID %>.setTitle('');
      }

    This works fine. But now I want to change the FieldLabel of my LblPrice Label.
    How can I do that?

    E.g. a:



    
      <%=LblPrice.ClientID %>.fieldLabel(record.data['CURRENCY']);

    does not work and a method setFieldLabel does not exist.


    So... is there a way to change the field-Label?


    Regards,

    Martin


  2. #2

    RE: [CLOSED] Dynamically set field label in javascript

    Hi,

    The following recomendations are true if field is placed inside FormLayout


    1. You should have initial field label, even empty (FieldLabel="&amp;nbsp;")
    2. Use the following code to update label
    TextField1.label.update('new label');
  3. #3

    RE: [CLOSED] Dynamically set field label in javascript

    I'd like to point out that updating the .FieldLabel during an AjaxRequest (DirectEvent) in v1.0 will work as expected. No need for a workaround.

    Example

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Button1_Click(object sender, DirectEventArgs e)
        {
            this.TextField1.FieldLabel = this.TextField1.Text;
        }
    </script>
    
    <!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 Examples</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <ext:FormPanel runat="server" Title="Title" Height="185" Width="350" Padding="5">
                <Items>
                    <ext:TextField ID="TextField1" runat="server" FieldLabel="First Name" />
                </Items>
                <Buttons>
                    <ext:Button runat="server" Text="Submit" OnDirectClick="Button1_Click" />
                </Buttons>
            </ext:FormPanel>
        </form>
    </body>
    </html>
    Hope this helps.

    Geoffrey McGill
    Founder
  4. #4

    RE: [CLOSED] Dynamically set field label in javascript

    Hi Geoffrey,

    thanks you very much for the information!
    One reason more to change to 1.0 as soon as possible :-)

    Regards,
    Martin

Similar Threads

  1. RTL Field label
    By azooz in forum 1.x Help
    Replies: 0
    Last Post: May 21, 2012, 11:57 AM
  2. [CLOSED] Field Label not work with ext:SpinnerField
    By stoque in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Nov 28, 2011, 8:03 PM
  3. [CLOSED] Display Field V/s Label
    By amitpareek in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Sep 06, 2011, 1:14 PM
  4. Replies: 3
    Last Post: Jul 08, 2010, 1:19 PM
  5. How to dynamically add label to panel?
    By omeriko9 in forum 1.x Help
    Replies: 3
    Last Post: Sep 07, 2009, 1:01 PM

Posting Permissions