This is a migrated thread and some comments may be shown as answers.

Update value without refreshing entire control/page

3 Answers 206 Views
Gauge
This is a migrated thread and some comments may be shown as answers.
jfkrueger
Top achievements
Rank 1
jfkrueger asked on 14 Jun 2011, 04:38 PM
I have finally gotten my gauges working correctly. The gaugues get their values based on a drop-down selection in the hosting .aspx page. When the drop-down changes, I would like the silverlight gauges to update their values. I am able to do this, however the entire page has to refresh which causes the control to dissappear, then appear again and reload. Is there a less "clunky" way of updating the values that the control uses  so that it is only the needles in the gauges updating rather than the entire control dissappearing and reloading?

Thanks!

3 Answers, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 16 Jun 2011, 02:06 PM
Hi jfkrueger,

I think you can use javascript functionality to set the value to the gauge control.
I have attached a sample solution which uses the GaugeValue scriptable member of the silverlight gauge control from javascript code to set a value to the needle indicator.

All the best,
Andrey Murzov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
jfkrueger
Top achievements
Rank 1
answered on 27 Jun 2011, 08:51 PM
What if I had the selector as part of the silverlight control rather than in the .aspx page (like how the sales dashboard is)?
0
Andrey
Telerik team
answered on 30 Jun 2011, 09:49 AM
Hi jfkrueger,

You can use any appropriate element which allows to select the value for a gauge. The following example uses the ComboBox and its SelectionChanged event to change the value of the needle:
 
<UserControl x:Class="SelectGaugeValue.MainPage"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400"
    Width="300" Height="330">
    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="3*" />
        </Grid.RowDefinitions>
        <ComboBox x:Name="comboBox" Height="30" Width="200" SelectionChanged="ComboBox_SelectionChanged">
            <sys:Double>0</sys:Double>
            <sys:Double>10</sys:Double>
            <sys:Double>30</sys:Double>
            <sys:Double>50</sys:Double>
            <sys:Double>80</sys:Double>
        </ComboBox>
        <telerik:RadGauge Grid.Row="1">
            <telerik:RadialGauge>
                <telerik:RadialScale>
                    <telerik:IndicatorList>
                        <telerik:Needle x:Name="needle" IsAnimated="True"/>
                    </telerik:IndicatorList>
                </telerik:RadialScale>
            </telerik:RadialGauge>
        </telerik:RadGauge>
    </Grid>
</UserControl>

using System.Windows.Controls;
 
namespace SelectGaugeValue
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
 
            this.comboBox.SelectedIndex = 0;
            this.needle.Value = 0;
        }
 
        private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems != null && e.AddedItems.Count > 0)
            {
                this.needle.Value = (double)e.AddedItems[0];
            }
        }
    }
}

Kind regards,
Andrey Murzov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Gauge
Asked by
jfkrueger
Top achievements
Rank 1
Answers by
Andrey
Telerik team
jfkrueger
Top achievements
Rank 1
Share this question
or