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

How to bind the "Maximum" Value of Slider in GridView Filter

11 Answers 136 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tolga
Top achievements
Rank 1
Tolga asked on 26 May 2010, 10:45 PM
Hi:
I have implemented the "Custom Filter Control" example where you have a slider control in the filter area for "Stadium Capacity". Instead of hard-coding the Maximum to 50000 is there a way to bind it to the maximum value found in the original (not filtered) data set?

Thanks
--tolga

11 Answers, 1 is accepted

Sort by
0
Yavor Georgiev
Telerik team
answered on 27 May 2010, 01:02 PM
Hi Tolga,

 Simply replace the declaration for the Maximum property in the SliderFilteringControl class from the example with this:

public int Maximum
{
    get { return (int)GetValue(MaximumProperty); }
    set { SetValue(MaximumProperty, value); }
}
 
public static readonly DependencyProperty MaximumProperty =
    DependencyProperty.Register("Maximum", typeof(int), typeof(SliderFilteringControl), new PropertyMetadata(0, new PropertyChangedCallback(this.OnMaximumPropertyChanged));
 
private void OnMaximumPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
    this.slider.Maximum = (int)e.NewValue;
}

Then you can bind it like so:
<local:SliderFilteringControl Minimum="0" Maximum="{Binding MyValue}"/>
 
Regards,
Yavor Georgiev
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
Michele
Top achievements
Rank 2
answered on 12 Aug 2010, 03:01 PM
I'm facing the same problem that tolga posted on May.... I want (if possible) that the Max (and in my case, the Min also) to be set with the  Min/Max of the DataSource I bound... in the way you wrote, I should pass the value from a resource defined in the top ... I just want something as the normal filter does (for example it shows all the possible value, so it passes on the datasource and do a distinct)

Thanks
Paolo
0
Yavor Georgiev
Telerik team
answered on 13 Aug 2010, 12:01 PM
Hello Paolo,

 Simply modify the Prepare method of SliderFilteringControl like so:

public void Prepare(GridViewBoundColumnBase column)
        {
            if (this.column != column)
            {
                this.column = column;
                string dataMemberName = this.column.DataMemberBinding.Path.Path;
 
                var distinctValues = column.DataControl.GetDistinctValues(column, false) as IEnumerable<int>;
                this.Minimum = distinctValues.Min();
                this.Maximum = distinctValues.Max();
 
                SliderFilterViewModel vm = new SliderFilterViewModel(dataMemberName
                    , this.column.DataControl.FilterDescriptors
                    , this.Minimum
                    , this.Maximum);
 
                Binding binding = new Binding("IsActive")
                {
                    Source = vm,
                    Mode = BindingMode.OneWay
                };
                this.ClearValue(SliderFilteringControl.IsActiveProperty);
                this.SetBinding(SliderFilteringControl.IsActiveProperty, binding);
 
                this.DataContext = vm;
            }
        }

Kind regards,
Yavor Georgiev
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
Michele
Top achievements
Rank 2
answered on 13 Aug 2010, 01:35 PM
Thanks, it worked....just another question, since I've got a quite huge range (in decimal), that starts from  ~ -4,000,000 to +2,000,000 how can I set a step? right now when I show the slider it shows me a lot of values ...
Thanks

Paolo
0
Yavor Georgiev
Telerik team
answered on 13 Aug 2010, 03:49 PM
Hello Paolo,

 Check out this demo.

Sincerely yours,
Yavor Georgiev
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
Tolga
Top achievements
Rank 1
answered on 29 Oct 2010, 01:25 AM
SO this works great, but is there a reason why this exact same approach would NOT work for "SelectionEnd" and "SelectionStart"? I am trying to build a generic re-usable control which basically has Minimum, Maximum, SelectionEnd, SelectionStart, MinimumRange, and MaximumRange all bound using dependency properties. I am able to get it to work for Minimum and Maximum, but not for SelectionStart or End.

Thanks

--tolga
0
Yavor Georgiev
Telerik team
answered on 29 Oct 2010, 11:08 AM
Hello Tolga,

 Could you please share a code snippet? What exactly is your approach and how does it not work?

Regards,
Yavor Georgiev
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
Tolga
Top achievements
Rank 1
answered on 02 Nov 2010, 05:50 PM
ViewModel

 

 

private Double _maximumNumberOfKeys;

 

 

 

public Double MaximumNumberOfKeys

 

{

 

 

get

 

{

 

 

return _maximumNumberOfKeys;

 

}

 

 

set

 

{

_maximumNumberOfKeys =

 

value;

 

OnPropertyChanged(

 

"MaximumNumberOfKeys");

 

}

}

 

 

private Double _selectedMaxNumberOfKeys;

 

 

 

public Double SelectedMaxNumberOfKeys

 

{

 

 

get

 

{

 

 

return _selectedMaxNumberOfKeys;

 

}

 

 

set

 

{

_selectedMaxNumberOfKeys =

 

value;

 

OnPropertyChanged(

 

"SelectedMaxNumberOfKeys");

 

}

}

 

 

public MainViewModel()

 

{

 

 

this.MaximumNumberOfKeys = 200;

 

 

 

this.SelectedMaxNumberOfKeys = 200;

 

OnPropertyChanged(

 

"MaximumNumberOfKeys");

 

OnPropertyChanged(

 

"SelectedMaxNumberOfKeys");

 

}



XAML

<

 

 

telerik:RadSlider Minimum="0"

 

 

 

Maximum="{Binding MaximumNumberOfKeys}"

 

 

 

SelectionStart="0"

 

 

 

SelectionEnd="{Binding SelectedMaxNumberOfKeys}"

 

 

 

MinimumRangeSpan="0"

 

 

 

MaximumRangeSpan="{Binding MaximumNumberOfKeys}"

 

 

 

IsSelectionRangeEnabled="True"

 

 

 

TickPlacement="TopLeft" />

 



So, both sliders are at 0. The "SelectionEnd" slider is not at "200" how I set it in the viewmodel. But the Maxium correctly displays "200" how I set it in the viewmodel. So, one works the other doesn't.

Thanks

--tolga
0
Tina Stancheva
Telerik team
answered on 05 Nov 2010, 01:48 PM
Hello Tolga,

Have you tested this with the Beta version of the RadControls? Because we had this issue and we fixed it so it should work as expected now.

Can you please give it a try and let us know if you still experience the issue? Thank you in advance.

Greetings,
Tina Stancheva
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
Tolga
Top achievements
Rank 1
answered on 09 Nov 2010, 08:30 PM
No I haven't. Where are the beta controls?
0
Petar Mladenov
Telerik team
answered on 10 Nov 2010, 05:57 PM
Hello Tolga,

You can find it here : http://www.telerik.com/community/labs/betas.aspx

However, we just released the Q3 2010 official version of our controls and it is available for download from the "YourProducts" section in your account. Please test the issue with that version and let us know if you still experience it.

Best wishes,
Petar Mladenov
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
GridView
Asked by
Tolga
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
Michele
Top achievements
Rank 2
Tolga
Top achievements
Rank 1
Tina Stancheva
Telerik team
Petar Mladenov
Telerik team
Share this question
or