PDA

View Full Version : [CLOSED] How to programaticaly set the value of a slider?



feanor91
Jun 08, 2012, 9:13 AM
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?

Daniil
Jun 08, 2012, 9:24 AM
Hi,

By default we use MultiSlider.
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.slider.Multi-method-setValue

So, the first argument should be a thumb index.

App.Slider1.setValue(0, 10);

feanor91
Jun 08, 2012, 2:56 PM
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.

Daniil
Jun 08, 2012, 3:33 PM
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>

feanor91
Jun 11, 2012, 7:41 AM
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.

feanor91
Jun 11, 2012, 8:29 AM
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.

feanor91
Jun 11, 2012, 8:45 AM
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.

Daniil
Jun 11, 2012, 9:55 AM
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.

feanor91
Jun 11, 2012, 12:35 PM
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.

Daniil
Jun 11, 2012, 2:33 PM
Hard to say.

Well, according that

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.