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

RadComboBox on Filter doesn't display selected text when using LoadOnDemand

2 Answers 60 Views
Filter
This is a migrated thread and some comments may be shown as answers.
Ashley
Top achievements
Rank 1
Ashley asked on 29 Oct 2013, 05:43 PM
I have a RadFilter with multiple RadFilterDropDownEditors with DropDownType RadComboBox. All of these I've set the DataSource in the ExpressionItemCreated Event.

Because of the size of the dataset for one of the combox boxes, I'm trying to use LoadOnDemand like so:

protected void RadFilter1_ExpressionItemCreated(object sender, RadFilterExpressionItemCreatedEventArgs e)
{
    var singleItem = e.Item as RadFilterSingleExpressionItem;
    if (singleItem != null && singleItem.IsSingleValue)
    {
        if(singleItem.InputControl is RadComboBox)
        {
            var dropDownList = singleItem.InputControl as RadComboBox;
 
            switch (singleItem.FieldName)
            {
                case "Security":
                    dropDownList.EnableLoadOnDemand = true;
                    dropDownList.ShowMoreResultsBox = true;
                    dropDownList.EnableVirtualScrolling = true;
                    dropDownList.WebServiceSettings.Method = "GetSecurityNames";
                    dropDownList.WebServiceSettings.Path = "DataSetPopup.aspx";
                    break;
            }
        }
    }
}

This works pretty well, but as soon as I click to add a new expression or load the filter from saved data, it no longer remembers the Selected Text value - it's blank. It remembers the SelectedValue, and the numeric value appears in the Filter Expression below the control, but I need it to display the text value as well.

Is there an event where I can get the selected value and set the Text field of the combo box?

Here's the markup for the filter if that helps
<rad:RadFilter runat="server" ID="RadFilter1" OnFieldEditorCreating="RadFilter1_FieldEditorCreating" OnApplyExpressions="RadFilter1_ApplyExpressions" OnExpressionItemCreated="RadFilter1_ExpressionItemCreated"  ExpressionPreviewPosition="Bottom" ShowApplyButton="false" AllowFilterOnBlur="true"  SettingsFormatter="BinaryFormatter">
     <FieldEditors>
           <rad:RadFilterDropDownEditor FieldName="Currency" DataTextField="IsoCurrencyCode" DataValueField="CurrencyId" DropDownType="RadComboBox"   />
           <rad:RadFilterDropDownEditor FieldName="Country" DataTextField="CountryDesc" DataValueField="CountryId" DropDownType="RadComboBox"/>                         
           <rad:RadFilterDropDownEditor FieldName="Region" DataTextField="RegionDesc" DataValueField="RegionId" DropDownType="RadComboBox"/>                         
           <rad:RadFilterDropDownEditor FieldName="Security" DataTextField="Security" DataValueField="SecurityId"  DropDownType="RadComboBox" />
      </FieldEditors>
</rad:RadFilter>


2 Answers, 1 is accepted

Sort by
0
Ashley
Top achievements
Rank 1
answered on 29 Oct 2013, 07:05 PM
I didn't realize the SelectedValue of the dropdownlist was already set when the ExpressionItemCreated event was fired.

I was able to set the text doing this, but it requires a database call each time - is there a way to get the text from the combobox based on the id?

case "Security":
   dropDownList.EnableLoadOnDemand = true;
   dropDownList.ShowMoreResultsBox = true;
   dropDownList.EnableVirtualScrolling = true;
   dropDownList.WebServiceSettings.Method = "GetSecurityNames";
   dropDownList.WebServiceSettings.Path = "DataSetPopup.aspx";
   int id;
   if(int.TryParse(dropDownList.SelectedValue, out id))
   {
       var security = GetSecurity(id);
       dropDownList.Text = security.SecurityShortName;
   }
   break;
0
Accepted
Antonio Stoilkov
Telerik team
answered on 01 Nov 2013, 02:34 PM
Hi Ashley,

The approach that you are currently using is correct. You could not have the access to the Text value without performing a request because the RadComboBox does not have its items when LoadOnDemand is enabled. 

Regards,
Antonio Stoilkov
Telerik
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 the blog feed now.
Tags
Filter
Asked by
Ashley
Top achievements
Rank 1
Answers by
Ashley
Top achievements
Rank 1
Antonio Stoilkov
Telerik team
Share this question
or