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

12 posts, 0 answers
  1. Tolga
    Tolga avatar
    28 posts
    Member since:
    Jun 2007

    Posted 26 May 2010 Link to this post

    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
  2. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 27 May 2010 Link to this post

    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.
  3. DevCraft banner
  4. Paolo
    Paolo avatar
    423 posts
    Member since:
    Jun 2009

    Posted 12 Aug 2010 Link to this post

    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
  5. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 13 Aug 2010 Link to this post

    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
  6. Paolo
    Paolo avatar
    423 posts
    Member since:
    Jun 2009

    Posted 13 Aug 2010 Link to this post

    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
  7. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 13 Aug 2010 Link to this post

    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
  8. Tolga
    Tolga avatar
    28 posts
    Member since:
    Jun 2007

    Posted 28 Oct 2010 Link to this post

    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
  9. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 29 Oct 2010 Link to this post

    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
  10. Tolga
    Tolga avatar
    28 posts
    Member since:
    Jun 2007

    Posted 02 Nov 2010 Link to this post

    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
  11. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 05 Nov 2010 Link to this post

    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

  12. Tolga
    Tolga avatar
    28 posts
    Member since:
    Jun 2007

    Posted 09 Nov 2010 Link to this post

    No I haven't. Where are the beta controls?
  13. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 10 Nov 2010 Link to this post

    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
Back to Top
DevCraft banner