[CLOSED] How to programaticaly set the value of a slider?

  1. #1

    [CLOSED] How to programaticaly set the value of a slider?

    Hello

    Please look at this example :

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html>
    
    <html>
    <head id="Head1" runat="server">
        <title>Slider - Ext.NET Examples</title>
        
        <script type="text/javascript">
            var SetSliderValue = function ()
            {
                App.Slider1.setValue( 10 );
            }
        </script>
    
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
            
            
            <h3>Set Slider Value</h3>
            
            <ext:Slider ID="Slider1" runat="server" Width="214" />
            
            <br/>
    
            <ext:Button runat="server" ID="btnTest" Text="Click on me">
                <Listeners>
                    <Click Fn="SetSliderValue"></Click>
                </Listeners>
            </ext:Button>
            
        </form>
    </body>
    </html>
    Not working, error :
    Uncaught TypeError: Cannot read property 'value' of undefined ext.axd:21
    So how to do?
    Last edited by Daniil; Jun 11, 2012 at 9:53 AM. Reason: [CLOSED]
  2. #2
    Hi,

    By default we use MultiSlider.
    http://docs.sencha.com/ext-js/4-1/#!...ethod-setValue

    So, the first argument should be a thumb index.
    App.Slider1.setValue(0, 10);
  3. #3
    Hello

    Works like a charm in example and on first slider in my window, but not on the second slider I have...Strange, I willdig into monday.
  4. #4
    I am unable to reproduce.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <ext:ResourceManager runat="server" />
        <ext:Slider 
            ID="Slider1" 
            runat="server" 
            Width="200" 
            Numbers="10,50" />
    
        <ext:Button runat="server" Text="Set values">
            <Listeners>
                <Click Handler="App.Slider1.setValue(0, 30);
                                App.Slider1.setValue(1, 70);" />
            </Listeners>
        </ext:Button>
    </body>
    </html>
  5. #5
    Hello

    Yes, I know, me to in the example, but in my application, slider1 move but not slider2 and and didn't know why for the moment. Besides that as I have a lott on error on chart, I'm not seeing for now, if I have an error on slider2 :
    Error: Invalid value for <rect> attribute y="NaN" Desktop.aspx:1
    Error: Invalid value for <rect> attribute height="NaN" Desktop.aspx:1
    Error: Invalid value for <rect> attribute y="NaN" Desktop.aspx:1
    Error: Invalid value for <rect> attribute height="NaN" Desktop.aspx:1
    Error: Invalid value for <rect> attribute y="NaN" Desktop.aspx:1
    Error: Invalid value for <rect> attribute height="NaN" Desktop.aspx:1
    Error: Invalid value for <rect> attribute y="NaN" Desktop.aspx:1
    Error: Invalid value for <rect> attribute height="NaN" Desktop.aspx:1
    Error: Invalid value for <rect> attribute y="NaN" Desktop.aspx:1
    Error: Invalid value for <rect> attribute height="NaN" Desktop.aspx:1
    Error: Invalid value for <rect> attribute y="NaN"
    I make something else now, but I will try to see that slider problem later.
  6. #6
    Ah, ah, ah....

    I dying from laughting....Just to try I have inverted the 2 lines:

        App.sldHorizontalChart.setValue( 0, INT_HorizontalCharts );
        App.sldVerticalChart.setValue( 0, INT_VerticalCharts );
    here sldHorizontalChart is updated and not sldVerticalChart.

        App.sldVerticalChart.setValue( 0, INT_VerticalCharts );
        App.sldHorizontalChart.setValue( 0, INT_HorizontalCharts );
    here sldVerticalChart is updated and not sldHorizontalChart....

    Mighty magic is acting on that.
  7. #7
    Problem solved.

    Instead of executing the 2 positioning into the same function called by the show event of the window, I called 2 function attached themselves to the AfterRender even of each slider.
  8. #8
    Ok, thanks for the update.

    If you could provide an example to reproduce the initial problem, I would try to investigate the source of the problem.
  9. #9
    Unable to reproduce into the example. I will not be able to give an example it seems to be related to something in my code, but I couldn't provide an exerpt because all is intricated, some parts are code behind gerated, over not, so what is interfering?

    But the point is I have a solution, so no problem.
  10. #10
    Hard to say.

    Well, according that
    Quote Originally Posted by feanor91 View Post
    Instead of executing the 2 positioning into the same function called by the show event of the window, I called 2 function attached themselves to the AfterRender even of each slider.
    I guess you just need a Window, two sliders and your JavaScript to reproduce the problem with a simple example. Though I am not 100% sure it will be enough to reproduce.

Similar Threads

  1. Problem with slider
    By JosefTrbusek in forum 1.x Help
    Replies: 0
    Last Post: Mar 07, 2012, 10:44 AM
  2. [CLOSED] Menu and Slider
    By Timothy in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jan 15, 2010, 7:01 PM
  3. [CLOSED] [1.0] Slider DataIndex
    By danielg in forum 1.x Legacy Premium Help
    Replies: 12
    Last Post: Nov 23, 2009, 5:00 AM
  4. Get Slider Value In TextBox
    By RS in forum 1.x Help
    Replies: 3
    Last Post: Feb 09, 2009, 7:04 AM
  5. [CLOSED] slider example
    By Lex in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Sep 22, 2008, 11:24 AM

Posting Permissions