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

Problem in Custom Filtering using RadCombox

3 Answers 74 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mohamed
Top achievements
Rank 1
mohamed asked on 14 Dec 2010, 06:32 PM

i tried using this method in creating a Custom Filter Column

http://www.telerik.com/help/aspnet/grid/grdfilteringwithdropdownlist.html
and it works fine but when i tried using the radcombobox instead of MS DropDown List the selceted index changed doesn't works so can anyone help me in this

public class FilteringTemplateColumns : GridBoundColumn
   {
 
       string _dataSourceID;
 
       public string DataSourceID
       {
           get { return _dataSourceID; }
           set { _dataSourceID = value; }
       }
 
       string _dataTextField;
 
       public string DataTextField
       {
           get { return _dataTextField; }
           set { _dataTextField = value; }
       }
 
       string _dataValueField;
 
       public string DataValueField
       {
           get { return _dataValueField; }
           set { _dataValueField = value; }
       }
 
       protected override void SetupFilterControls(TableCell cell)
       {
           base.SetupFilterControls(cell);
           cell.Controls.RemoveAt(0);
           RadComboBox rcBox = new RadComboBox();
           rcBox.ID = "cmb" + this.DataField;
           rcBox.AutoPostBack = true;
           rcBox.DataTextField = DataTextField;
           rcBox.DataValueField = DataValueField;
           rcBox.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(rcBox_SelectedIndexChanged);
           rcBox.DataSourceID = DataSourceID;
           rcBox.AppendDataBoundItems = true;
           rcBox.Items.Insert(0, new RadComboBoxItem("", ""));
           rcBox.Items.Insert(1, new RadComboBoxItem("All", "All"));
           cell.Controls.AddAt(0, rcBox);
           cell.Controls.RemoveAt(1);
       }
 
       void rcBox_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
       {
           RadComboBox list = sender as RadComboBox;
           GridFilteringItem filterItem = (sender as RadComboBox).NamingContainer as GridFilteringItem;
           if (this.DataType == System.Type.GetType("System.Int32") ||
               this.DataType == System.Type.GetType("System.Int16") ||
               this.DataType == System.Type.GetType("System.Int64"))
           {
               filterItem.FireCommandEvent("Filter", new Pair("EqualTo", this.UniqueName));
           }
           else // treat everything else like a string
           {
               if (list.SelectedValue != "All")
                   filterItem.FireCommandEvent("Filter", new Pair("Contains", this.UniqueName));
               else
                   filterItem.FireCommandEvent("Filter", new Pair("NoFilter", this.UniqueName));
           }
 
 
       }
 
 
 
       protected override void SetCurrentFilterValueToControl(TableCell cell)
       {
           base.SetCurrentFilterValueToControl(cell);
           RadComboBox list = (RadComboBox)cell.Controls[0];
           if (this.CurrentFilterValue != string.Empty)
           {
               list.Items.Clear();
               list.AppendDataBoundItems = true;
               list.DataBind();
               list.SelectedItem.Text = this.CurrentFilterValue;
               list.Items.Insert(0, new RadComboBoxItem("", ""));
               list.Items.Insert(1, new RadComboBoxItem("All", "All"));
           }
       }
 
       protected override string GetCurrentFilterValueFromControl(TableCell cell)
       {
           RadComboBox list = (RadComboBox)cell.Controls[0];
           return list.SelectedItem.Text;
       }
       protected override string GetFilterDataField()
       {
           return this.DataField;
       }
 
   }

3 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 17 Dec 2010, 12:06 PM
Hello Mohamed,

You can find sample implementation on the demo bellow:
http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandcombo/defaultcs.aspx?product=grid

Regards,
Nikolay
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
John S.
Top achievements
Rank 1
answered on 06 Jan 2011, 05:49 AM
I feel the need to rant about this...

After a considerable amount of time reviewing the demo page and associated code I discovered that the VB code is not complete and does not include the custom column code. If you assume this is an uninformed user not knowing what he is doing, you are correct. I have never needed to create a custom dropdown filter and therefore I look to an example for help. Without the custom column code it seems like everything is extremely simple and magic is happening somewhere (which could be the case as there could be behind-the-scenes code I don't need to know or need to know about).

I am finding that VB.NET code examples are frequently an afterthought and seems to be the C# code processed through a converter without testing.

This is not the first time I have seen this and it is very frustrating trying to figure out something that proports to be an example only to find there are missing pieces.



0
Nikolay Rusev
Telerik team
answered on 11 Jan 2011, 05:11 PM
Hello John,

Yes from time we receive reports that we've missed some VB code for examples and we are always open for such reports. Indeed if you open the examples locally you will be able to locate the missing VB code file for the example.

All the best,
Nikolay
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
mohamed
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
John S.
Top achievements
Rank 1
Share this question
or