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

RadFilter custom controls problem

3 Answers 60 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
michelle
Top achievements
Rank 1
michelle asked on 30 Sep 2011, 03:07 PM
I can use the sample code to create a drop down for the possible values of a field (i.e. to the right hand side of the greater than or equal to or whatever)
However, I want to put a combo box in the place of the field selector itself (the left hand side of the greater than / equal to)
I can successfully create the combo box, but then it appears in the wrong place (the right hand side).  See the code that does this below.

So I tried putting it at position 0..  In InitializeEditor, instead of this line: 

container.Controls.Add(_combo);

I had:
container.Controls.AddAt(0);

This puts it in the correct place, but then I cannot work out how to add the functionality that ensures that when the user clicks on
a particular entry, the text box appears to the right of the greater than/ equal to section?

I think I have to capture the onselected event from the combo box and then create the appropriate textbox control right?
PLEASE HELP!

RadFilterDropDownEditor dropDownFieldEditor = new RadFilterDropDownEditor();
RadFilter1.FieldEditors.Add(dropDownFieldEditor);
  
DataTable dt = MakeTable();

//create the list of fields to select on
foreach (FilterFieldDTO dtoField in filterOptionList)
{
    DataRow row;
    row = dt.NewRow();
      
    row["FieldName"] = dtoField.FieldName;
    string strFieldName;
    if (row["FieldName"].ToString().LastIndexOf(".") > -1)
    {
        strFieldName = row["FieldName"].ToString().Substring(row["FieldName"].ToString().LastIndexOf(".") + 1);
    }
    else
    {
        strFieldName = row["FieldName"].ToString();
    }
      
    row["FieldName"] = strFieldName;
    
    row["DataValueField"] = strFieldName;
    row["DataTextField"] = strFieldName;
    dt.Rows.Add(row);
 }
  
dropDownFieldEditor.DataTextField = "DataTextField";
dropDownFieldEditor.DataValueField = "DataValueField";
dropDownFieldEditor.FieldName = "FieldName";
  
dropDownFieldEditor.DataSource = dt;

3 Answers, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 05 Oct 2011, 08:21 AM
Hello Michelle,

You need to manually add the textbox in the InitializeEditor method. Then,after adding the filter expression on selected index changed of the combo, you need to call explicitly the RecreateControl() method of the RadFilter. RecreateControl will recreate all controls in the custom editor and the TextBoxes may disappear, so you need to create them every time when InitializeEditor is called.

However, please note that this is a custom scenario and it is out of our scope to implement and support it.

Greetings,
Mira
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Bobby
Top achievements
Rank 1
answered on 05 Oct 2011, 12:52 PM

container.Controls.AddAt(2, _textbox);

 

 

if (container.Controls.Count > 2)

 

{

container.Controls.RemoveAt(2);

}

 

 

 

RadFilterEqualToFilterExpression<String> expr1 = new RadFilterEqualToFilterExpression<string>(fieldEditor.FieldName);

 

expr1.Value = _textbox.Text;

RadFilterParent.RootGroup.AddExpression(expr1);

 

RadFilterParent.RecreateControl();

//here it gives an exception -  Collection was modified; enumeration operation may not execute



Is there some way to replace the existing control rather than add a new one and remove the other one?
Or is that not the cause of my problem?  Is it because this piece of code is being run more than once per postback?
0
Mira
Telerik team
answered on 06 Oct 2011, 11:21 AM
Hello Bobby,

Our system indicates that you have opened a support ticket concerning the same issue. In order to avoid duplicate posts, I suggest that the communication continues in the support ticket only.

Greetings,
Mira
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
General Discussions
Asked by
michelle
Top achievements
Rank 1
Answers by
Mira
Telerik team
Bobby
Top achievements
Rank 1
Share this question
or