The properties of numberfield can not be changed from code-behind in the direct event.

  1. #1

    The properties of numberfield can not be changed from code-behind in the direct event.

    The following is the markup code.

           <ext:Window ID="winCtl" runat="server" Collapsible="false" AutoHeight="true" Icon="ApplicationForm"
                Width="400" Hidden="true" Draggable="true" Resizable="false" Modal="true">
                <Items>
                    <ext:FormPanel ID="fpnlCtl" runat="server" ButtonAlign="Right" AutoHeight="true" Header="false" 
                        BodyStyle="background-color:transparent;" Padding="5" LabelAlign="Right" LabelWidth="100">
                        <Items>
                            <ext:Hidden ID="hideActionCtl" runat="server" />
                            <ext:ComboBox ID="ddlCtlPara" runat="server" FieldLabel="Control Parameter" AnchorHorizontal="95%" AllowBlank="false" ForceSelection="true">
                               <Items>
                                    <ext:ListItem Text="D" Value="D" />
                                    <ext:ListItem Text="H" Value="H" />
                                    <ext:ListItem Text="T" Value="T" />
                                </Items>
                                <DirectEvents>
                                    <Select OnEvent="ddlCtlPara_SelectedIndexChanged">
                                        <ExtraParams>
                                            <ext:Parameter Name="CtlPara" Value="#{ddlCtlPara}.getValue()" Mode="Raw" />
                                        </ExtraParams>
                                    </Select>
                                </DirectEvents>
                            </ext:ComboBox>
                            <ext:NumberField ID="txtMAXParaValue" runat="server" FieldLabel="MAXParaValue" AnchorHorizontal="95%" AllowNegative="false" AllowDecimals="false" />
                            <ext:ComboBox ID="ddlCAType" runat="server" FieldLabel="CA Standard" AnchorHorizontal="95%" />
                        </Items>
                    </ext:FormPanel>
                </Items>
            </ext:Window>
    The following is the code-behind.

            protected void ddlCtlPara_SelectedIndexChanged(object sender, DirectEventArgs e)
            {
                string strCtlPara = e.ExtraParams["CtlPara"];
                if (strCtlPara== "D")
                {
                    txtMAXParaValue.AllowDecimals = false; // Does not work.
                    // txtMAXParaValue.Disabled = true; // It works.
                    ddlCAType.ForceSelection = true;
                    ddlCAType.AllowBlank = false;
                    ddlCAType.Disabled = false;                
                }
                else
                {
                    if (strCtlPara == "H")
                    {
                        txtMAXParaValue.AllowDecimals = true; // Does not work.
                        txtMAXParaValue.DecimalPrecision = 2; // Does not work.
    // txtMAXParaValue.Disabled = false; // It works.
                    }
                    else
                    {
                        txtMAXParaValue.AllowDecimals = false; // Does not work.
                        // txtMAXParaValue.Disabled = true; // It works.
                    }
                    ddlCAType.ForceSelection = false;
                    ddlCAType.AllowBlank = true;
                    ddlCAType.SelectedItem.Value = "";
                    ddlCAType.Disabled = true;
                }
            }
    Problem Description:
    The property of "AllowDecimals" is not changed after the 'H' is selected. But the property of "Disabled" can be changed correctly. Others work fine.

    Can anyone tell me the reason? It's very strange.

    Thanks a lot.
    Last edited by Santon_Lee; Mar 29, 2011 at 7:36 AM.
  2. #2
    I have the same problem here... I'm trying to change the AllowBlank property... but nothing happend.

    Maybe it's a Bug?
  3. #3
    Thi is my the code with a ComboBox and Numberfield

    <ext:ComboBox ID="TdtCodigo" runat="server" Editable="false" AutoWidth="true" StoreID="TdtCodigoStore"  ValueField="Codigo" DisplayField="Nombre" FieldLabel="<%$ Resources:BaseLocalizedText, CamposTablas_TdtCodigo_Mantenimiento%>">
                        <DirectEvents>
                            <Select OnEvent="LengthVal" IsUpload="true">
                                <ExtraParams>
                                    <ext:Parameter Name="TipoDato" Value="#{TdtCodigo}.getValue()" Mode="Raw" Encode="true" />
                                </ExtraParams>
                            </Select>
    
                            <AfterRender OnEvent="LengthVal" IsUpload="true">
                                <ExtraParams>
                                    <ext:Parameter Name="TipoDato" Value="#{TdtCodigo}.getValue()" Mode="Raw" Encode="true" />
                                </ExtraParams>
                            </AfterRender>
                        </DirectEvents>
    				</ext:ComboBox>
    				<ext:NumberField ID="Longitud" runat="server" allowDecimals="false" AllowBlank="false" FieldLabel="<%$ Resources:BaseLocalizedText, CamposTablas_Longitud_Mantenimiento%>" Width="70" ReadOnly="true" Cls="FondoTexto" />
    This is the CodeBehind Code:
        protected void LengthVal(object sender, DirectEventArgs e)
        {
            string l_strLongitud;
            string l_strMaxValue;
            string l_strTipoDato = e.ExtraParams["TipoDato"].ToString().Trim();
            double l_dblTipoDato;
    
            bool isNum = double.TryParse(l_strTipoDato, out l_dblTipoDato);
            if (isNum)
                l_strTipoDato = e.ExtraParams["TipoDato"].ToString().Trim();
            else
                l_strTipoDato = "0";
            
            // Example Values
            l_strLongitud = "0";
            char[] l_charSeparator = ".";
            
            if (l_strLongitud == "0")
            {
    
                // Si no hay una Longitud por Defecto
                Longitud.Clear();
                Longitud.ReadOnly = false;
                Longitud.Cls = "";
                
                Longitud.Regex = "\d{1,2}.\d{1,2}";
                Longitud.RegexText = "Only decimal values";
                l_strMaxValue = "48.48";
                
                if (l_strMaxValue.Split(l_charSeparator).Length == 1)
                {
                    Longitud.AllowDecimals = false;
                    Longitud.DecimalPrecision = 0;
                    Longitud.MaxValue = Convert.ToInt32(l_strMaxValue);
                }
                else
                {
                    Longitud.AllowDecimals = true;
                    Longitud.DecimalPrecision = Convert.ToInt32( l_strMaxValue.Split(l_charSeparator)[1].Length.ToString() );
                    Longitud.MaxValue = Convert.ToDouble( l_strMaxValue.Split(l_charSeparator)[0] );
                    Longitud.MaxValue += Convert.ToDouble( l_strMaxValue.Split(l_charSeparator)[1] ) / Math.Pow(10, Longitud.DecimalPrecision);
                }
            }
            else
            {
                // Si hay una longitud por Defecto
                Longitud.SetValue(l_strLongitud);
                Longitud.ReadOnly = true;
                Longitud.Cls = "FondoTexto";
    
                Longitud.Regex = "";
                Longitud.RegexText = "";
                Longitud.AllowDecimals = false;
                Longitud.DecimalPrecision = 0;
                Longitud.MaxValue = Convert.ToInt32(l_strLongitud);
            }
        }
    </script>
  4. #4
    Maybe is because i'm using UserControl?

    I'm trying to with

     X.GetCmp<NumberField>(Longitud.ClientID).AllowDecimals = true;
    But... nothing happend!
  5. #5
    Quote Originally Posted by inaltec View Post
    Maybe is because i'm using UserControl?

    I'm trying to with

     X.GetCmp<NumberField>(Longitud.ClientID).AllowDecimals = true;
    But... nothing happend!
    I think you might need to re-render the Component after setting this property.

    After you set your new properties values, call .Render() on the Component. This will force a re-render.

    Hope this helps.
    Geoffrey McGill
    Founder

Similar Threads

  1. [CLOSED] Output Cache issue with Direct Method / Direct Event
    By amitpareek in forum 1.x Legacy Premium Help
    Replies: 18
    Last Post: Mar 01, 2013, 5:03 AM
  2. Replies: 3
    Last Post: Apr 19, 2011, 5:14 PM
  3. [CLOSED] Update a nodes iconcls and cls properties in direct method.
    By Labyrinth in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jul 02, 2010, 1:29 PM
  4. Replies: 3
    Last Post: Apr 20, 2010, 12:21 PM
  5. Checkbox changed handler in code-behind
    By drakaan in forum 1.x Help
    Replies: 6
    Last Post: Aug 24, 2009, 3:07 PM

Tags for this Thread

Posting Permissions