FilterText Box need to replaced with ComboBox

3 posts, 0 answers
  1. Hemanth
    Hemanth avatar
    24 posts
    Member since:
    Mar 2011

    Posted 13 Dec 2012 Link to this post

    Hi,

    In my SL application, i m generating columns dynamically in radgrid, even i have filters  and FilteringMode="FilterRow",
    now for filtering i have textbox, but i need to replace that textbox with ComboBox and bind data to that.

    can someone help me..


    Thanks
  2. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 13 Dec 2012 Link to this post

    Hi,

    The documentation is a good place to start.

    Greetings,
    Rossen Hristov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Hemanth
    Hemanth avatar
    24 posts
    Member since:
    Mar 2011

    Posted 13 Dec 2012 Link to this post

    Thanks Rossen for quick response,

    everything is ok for me, i m taking RadComboBox as filter

    on FilterEditorCreated, i m binding value to it, values are binding but they are not displayed


     if (e.Column.UniqueName.ToLower() == "text")
                {
                    Telerik.Windows.Controls.RadComboBox rcb = e.Editor as Telerik.Windows.Controls.RadComboBox;
                    if (rcb != null)
                    {

    objService.ServiceMethodCompleted += (s, evt) =>
                            {
                                //rcb.ItemsSource = evt.Result;

                                List<String> lstitems = (List<String>)evt.Result;
                                for (int i = 0; i < lstitems .Count; i++)
                                {
                                    //rcb.DisplayMemberPath = lstitems [i];
                                    rcb.Items.Add(lstitems [i]);
                                }

                            };
                        objService.ServiceMethodAsync();

                      }
    can u say where i m going wring?


    and my FilterEditor class


     public class BindDDLforFilter : Telerik.Windows.Controls.GridViewDataColumn
        {
            public override FrameworkElement CreateFieldFilterEditor()
            {
                Telerik.Windows.Controls.RadComboBox radComboBox = new Telerik.Windows.Controls.RadComboBox();
                // This binding will transfer the significant property of your editor to the filtering view model.
                Binding selectedValueBinding = new Binding("Value");
                selectedValueBinding.Converter = new ComboBoxFilterEditorConverter();

                radComboBox.SetBinding(Telerik.Windows.Controls.RadComboBox.SelectedValueProperty, selectedValueBinding);
                return radComboBox;
            }

            private class ComboBoxFilterEditorConverter : IValueConverter
            {
                public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
                {
                    if (Object.Equals(value, Telerik.Windows.Data.FilterDescriptor.UnsetValue))
                    {
                        // When the filter is turned off this is what editor will get.
                        return null;
                    }
                    return value;
                }

                public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
                {
                    if (value == null)
                    {
                        // When your editor want to turn off the filter this is what it should return.
                        return Telerik.Windows.Data.FilterDescriptor.UnsetValue;
                    }
                    return value;
                }
            }
        }
Back to Top