Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Ajax > Customize RadFilter's input fields to dropdownlist instead of textboxes
RadControls for ASP.NET are no longer supported (see this page for reference). In case you have inquiries about the Telerik ASP.NET AJAX controls, post them in the pertinent ASP.NET AJAX forums.

Not answered Customize RadFilter's input fields to dropdownlist instead of textboxes

Feed from this thread
  • Shannnon avatar

    Posted on Apr 15, 2011 (permalink)

    I am using AJAX RadFilter, I am wondering if I can change textboxes in Filter to dropdownlist, instead of making users to type in textbox to do filtering, I want to offer them a dropdownlist or combobox something similar to choose values from, is it even supported by Telerik now?

    Thanks!

  • Mira Mira admin's avatar

    Posted on Apr 20, 2011 (permalink)

    Hello Shannnon,

    I have followed your scenario and prepared a sample project for you demonstrating how the desired functionality can be implemented. You can find it attached to this message.

    I hope it helps.

    Regards,
    Mira
    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.

  • Shannnon avatar

    Posted on Apr 20, 2011 (permalink)

    Hi Mira,
    Thank you for your sample, it works. However, I got a little issue with it. I am using the Filter to filter the RadGrid, after I select values from dropdownlist and hit apply buttonto filter the grid and then come back to the Filter, I cannot close it by clicking the cross icon of that particular dropdownEditor, it just keep showing up. I can close it if I don't hit the apply button. Below is my code besides the CustomEditor class which is untouched from your sample: 
    protected void RadFilter2_OnLoad(object sender, EventArgs e)
          {
              RadFilterDropDownEditor _filterEditor = new RadFilterDropDownEditor();
              RadFilter2.FieldEditors.RemoveAt(0);
              RadFilter2.FieldEditors.Insert(0, _filterEditor);
              List<AccountCollection> _list = new List<AccountCollection>();
              _list.Add(new AccountCollection("Stage1", "0"));
              _list.Add(new AccountCollection("Stage2", "1"));
              _list.Add(new AccountCollection("Stage3", "2"));
              _filterEditor.DataTextField = "Name";
              _filterEditor.DataValueField = "Value";
              _filterEditor.FieldName = "Stage";
              _filterEditor.DataSource = _list;
          }

     

     

    protected void RadFilter2_FieldEditorCreating(object sender, RadFilterFieldEditorCreatingEventArgs e)

     

     

    {

     

    e.Editor =

     

    new RadFilterDropDownEditor();

     

     

    }

     

     

    protected void ApplyButton_Click(object sender, EventArgs e)

     

     

    {

     

    RadFilter2.FireApplyCommand();

     

    }

     

     

    and my Filter in aspx page:
    <telerik:RadFilter runat="server" ID="RadFilter2"  FilterContainerID="RadGrid1" ShowApplyButton="false" Skin="Office2007"   OnFieldEditorCreating="RadFilter2_FieldEditorCreating" OnLoad="RadFilter2_OnLoad" >
                      <FieldEditors>
                      </FieldEditors>
                  </telerik:RadFilter>
           <asp:Button runat="server" ID="ApplyButton" OnClick="ApplyButton_Click" Text="Apply Filter" />
    I can work around by closing all of them together but i just cannot close that dropdown filter item. I hope i addressed my issue clear enough.

    Thank you!

  • Mira Mira admin's avatar

    Posted on Apr 26, 2011 (permalink)

    Hello Shannnon,

    In order to configure the filter editors properly, I recommend that you use the following code:
    protected void Page_Load(object sender, EventArgs e)
    {
        RadFilterDropDownEditor _filterEditor = RadFilter1.FieldEditors[0] as RadFilterDropDownEditor;
     
        List<AccountCollection> _list = new List<AccountCollection>();
        _list.Add(new AccountCollection("Stage1", "0"));
        _list.Add(new AccountCollection("Stage2", "1"));
        _list.Add(new AccountCollection("Stage3", "2"));
        _filterEditor.DataTextField = "Name";
        _filterEditor.DataValueField = "Value";
        _filterEditor.FieldName = "Stage";
     
        _filterEditor.DataSource = _list;
    }
     
    protected void RadFilter1_FieldEditorCreating(object sender, RadFilterFieldEditorCreatingEventArgs e)
    {
        e.Editor = new RadFilterDropDownEditor();
    }

    I hope it helps.

    All the best,
    Mira
    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.

  • Shannnon avatar

    Posted on Apr 26, 2011 (permalink)

    Hi Mira,

    I got error "object is not set to an instance", _filterEditor is null all the time, seems RadFilterTextFieldEditor cannot be converted to RadFilterDropDownEditor using this way. When I cast it into RadFilterTextFieldEditor, _filterEditor returns an object. Any suggestion?

    Thank you.

  • Mira Mira admin's avatar

    Posted on Apr 29, 2011 (permalink)

    Hello Shannnon,

    What is your declaration of the field editors?
    It should look like the following:
    <telerik:RadFilter runat="server" ID="RadFilter1" FilterContainerID="SqlDataSource1"
        OnFieldEditorCreating="RadFilter1_FieldEditorCreating" ExpressionPreviewPosition="Bottom">
        <FieldEditors>
            <custom:RadFilterDropDownEditor FieldName="Fieldname" DataTextField="Text"
                DataValueField="Value" />
        </FieldEditors>
    </telerik:RadFilter>

    Also, you need to register the namespace in which the editor is defined:
    <%@ Register Namespace="CustomEditors" TagPrefix="custom" %>

    I hope this helps.

    Greetings,
    Mira
    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.

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Ajax > Customize RadFilter's input fields to dropdownlist instead of textboxes