[CLOSED] Set Increment in TimeField via javascript

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Set Increment in TimeField via javascript

    Hi,

    I have a TimeField and I need to set the increment dynamically because every user has it's own configuration.
    Last edited by Baidaly; Mar 11, 2013 at 10:39 PM. Reason: [CLOSED]
  2. #2
    Hello,

    You can set the .Increment property, see docs:

    http://docs.sencha.com/ext-js/4-1/#!...-cfg-increment
    Geoffrey McGill
    Founder
  3. #3
    Hi,

    Yes, I did this:

    Ext.getCmp("horaInicio").increment = 10;
    but still didn't work. Is there any other way to set increment prop?
  4. #4
    I don't think you can change the .increment client-side after the component has rendered.

    How about just setting server-side?
    Geoffrey McGill
    Founder
  5. #5
    I tried:

    <Listeners>
         <AfterRender Fn="IncrementarMinutos" />
    </Listeners>
    
    <script>
         var IncrementarMinutos = function (value) {
              value.increment = 20;
    
              return value;
         };
    </script>
    And:

    <script type="text/javascript">
    $(document).ready(function () {
         $.MontarAgenda(0);
    });
    
    jQuery.MontarAgenda = function (id) {
         $.ajax({
                    url: "../Agenda/ObterMinutosDoUsuario/" + id,
                    success: function (retorno) {
                        $('#minutoHidden').val(retorno.minutos);
                    }
         });
    };
    </script>
    <script runat="server">
            protected void Incrementar(object sender, DirectEventArgs e)
            {
                if (minutoHidden.Value == "")
                {
                    horaInicio.Increment = 30;
                    horaFim.Increment = 30;
                }
                else
                {
                    horaInicio.Increment = Convert.ToInt32(minutoHidden.Value);
                    horaFim.Increment = Convert.ToInt32(minutoHidden.Value);
                }
            }
        </script>
    
    <input type="text" id="minutoHidden" runat="server" />
    
    <ext:Label ID="Label1" runat="server" Text="Hora " X="2" Y="170" Cls="LabelForm" />
                    <ext:TimeField ID="horaInicio" runat="server" MinTime="08:00" MaxTime="23:00" SelectedTime="09:00"
                        Format="H:mm" Width="100">
                        <DirectEvents>
                            <AfterRender OnEvent="Incrementar">
                                <EventMask ShowMask="true" Target="This" />
                            </AfterRender>
                        </DirectEvents>
                    </ext:TimeField>
    But didn't work.
  6. #6
    Hello!

    Geoffrey meant that you should set increment as configuration during Page_Load, not DirectEvent. As we understood you know increment value during Page_Load.

    <ext:TimeField ID="horaInicio" runat="server" MinTime="08:00" MaxTime="23:00" SelectedTime="09:00"
    	Format="H:mm" Width="100" Increment="20">
    </ext:TimeField>
  7. #7
    I need to set increment according to the user.
  8. #8
    At which moment do you know a user?
  9. #9
    <script type="text/javascript">
         $(document).ready(function () {
              $.MontarAgenda(Ext.getCmp("colaborador").getValue());
         });
     
         jQuery.MontarAgenda = function (id) {
              $.ajax({
                    url: "../Agenda/ObterMinutosDoUsuario/" + id,
                    success: function (retorno) {
                        $('#minutoHidden').val(retorno.minutos);
              }
         });
    };
    </script>
    
    <script runat="server">
            protected void Incrementar(object sender, DirectEventArgs e)
            {
                if (minutoHidden.Value == "")
                {
                    horaInicio.Increment = 30;
                    horaFim.Increment = 30;
                }
                else
                {
                    horaInicio.Increment = Convert.ToInt32(minutoHidden.Value);
                    horaFim.Increment = Convert.ToInt32(minutoHidden.Value);
                }
            }
    </script>
     
    <input type="text" id="minutoHidden" runat="server" />
  10. #10
    I don't understand well how it answers my question.
    At which moment do you know a user?
    But, seems, you need to set up an Increment during a DirectEvent. If so, then you have to re-render a TimeField.
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 2
    Last Post: May 21, 2012, 1:23 PM
  2. TimeField - Help
    By Jose Pereira dos anjos Júnior in forum 1.x Help
    Replies: 0
    Last Post: Jun 07, 2010, 2:09 AM
  3. [FIXED] [0.8.3] TimeField Bug
    By Timothy in forum Bugs
    Replies: 10
    Last Post: Jan 31, 2010, 4:06 PM
  4. [CLOSED] Increment value in Grid if Id is added several times
    By macap in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 21, 2010, 6:02 AM
  5. TimeField
    By jmilton in forum 1.x Help
    Replies: 0
    Last Post: May 27, 2009, 12:21 PM

Tags for this Thread

Posting Permissions