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

RadCheckedDropDownList change ContentElement Text

3 Answers 98 Views
CheckedDropDownList
This is a migrated thread and some comments may be shown as answers.
Christian
Top achievements
Rank 1
Christian asked on 05 Mar 2018, 12:29 PM

Hi,

I'm trying to change the text of the checked item of a RadCheckedDropDownList by using the TextBlockFormatting event.

TokenizedTextBlockElement token = e.TextBlock as TokenizedTextBlockElement;
if (token != null && token.Item.Value != null)
{
    token.DrawText = false;
    token.ContentElement.Text = string.Format("{0}", ((Telerik.WinControls.UI.RadListDataItem)token.Item.Value).Value);
}

 

this works, the items are displayed correctly. However, if there are multiple checked items and one item becomes unchecked (by using the X) the complete selection is cleared. The Datasource is a Dictionary<dynamic, string>(). Without the formatting everything works fine.

I've tried CreateTextBlock without any luck. I've seen there is some code with a custom TokenizedTextBlockElement, but I hope there is a simpler way?!
There should be a XXXMember property like the DescriptionTextMember, AutoCompleteDisplayMember otherwise there is nothing about RAD in your RAD components ... last time i checked RAD was short for Rapid Application Development and not investing 2+ hours for such a simple task. And NO I don't want to format the items in the dropdown since I have some dropdowns with >2000 Items and it becomes very slow if I add the formatting.

 

 

 

 

3 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 06 Mar 2018, 09:54 AM
Hello, Christian,

Thank you for writing.  

The DisplayMember property is purposed to indicate what text to be displayed for the items and tokens. I would suggest you another approach: try to format the items in the drop down: 
public RadForm1()
  {
      InitializeComponent();
 
      this.radCheckedDropDownList1.DataSource = this.customersBindingSource;
      this.radCheckedDropDownList1.DisplayMember = "CustomerID";
      this.radCheckedDropDownList1.ValueMember = "CustomerID";
 
      this.radCheckedDropDownList1.VisualListItemFormatting += radCheckedDropDownList1_VisualListItemFormatting;
      this.radCheckedDropDownList1.PopupClosing += radCheckedDropDownList1_PopupClosing;
  }
 
  private void radCheckedDropDownList1_PopupClosing(object sender, RadPopupClosingEventArgs args)
  {
      args.Cancel = true;
  }
 
  private void radCheckedDropDownList1_VisualListItemFormatting(object sender, VisualItemFormattingEventArgs args)
  {
      DataRowView rowView = args.VisualItem.Data.DataBoundItem as DataRowView;
      if (rowView != null)
      {
          RadCheckedListVisualItem item = args.VisualItem as RadCheckedListVisualItem;
          item.Label.ForeColor = Color.Transparent;
          item.CheckBox.Text = rowView.Row["ContactName"].ToString();
      }
  }

I hope this information helps. Should you have further questions I would be glad to help. 
 
  Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Christian
Top achievements
Rank 1
answered on 08 Mar 2018, 08:48 AM

Hi,

like I wrote, I know that I can format the items in the dropdown but for performance reasons I don't like that.

And if I use the formatting event/DisplayMember, the suggestion displayed while inputting by hand is cut to the value.

So a "Member" property for the textblock would be nice!

0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 08 Mar 2018, 01:05 PM
Hello, Christian,   

Thank you for writing back. 

Your feedback is greatly appreciated. The current implementation of RadCheckedDropDownList allows specifying only one DisplayMember which affects the displayed text in the drop down and the tokens in the editable part. This is by design in order to avoid any confusion when selecting a checked item.

If other customers have similar requests we will consider it in the future control's improvement. Meanwhile, feel free to use the suggested approach from my previous post.

I hope this information helps. If you have any additional questions, please let me know. 

 Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
CheckedDropDownList
Asked by
Christian
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Christian
Top achievements
Rank 1
Share this question
or