Tokenizer as selected Items

2 posts, 0 answers
  1. Ramachandran
    Ramachandran avatar
    8 posts
    Member since:
    Jul 2017

    Posted 25 Sep Link to this post

    Hi

    I have a datatable with id and 4 columns, I am using RadMultiComboBox and 
    RadMutliColumnComboBoxSelectionExtender,  My display member is one of the column in the datatable.
    I want the display value member is showed in the combobox,  I want the Ids should be tokenised as a string. 

    Please help me how to do this? Earliest reply is good.

  2. Hristo
    Admin
    Hristo avatar
    1016 posts

    Posted 27 Sep Link to this post

    Hello Ramachandran,

    Thank you for writing.

    You can set the DisplayMember to equal the value of the ValueMember. This way you would be able to display it in the editor of the drop-down. Please note however that this would not allow any customizations fo the text.

    If it would fit your setup you can add a field displaying the text the way you like to your data source and then use that field as a DisplayMember. Since this field would only be used to format the text in the editor you might also want to hide the respective column from the underlying grid. This can be done by setting is IsVisible property to false. Please check my code snippet below: 
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
     
            this.radMultiColumnComboBox1.DataSource = this.GetData();
            this.radMultiColumnComboBox1.DisplayMember = "DisplayMemberField";
            this.radMultiColumnComboBox1.ValueMember = "Id";
            this.radMultiColumnComboBox1.EditorControl.Columns["DisplayMemberField"].IsVisible = false;
        }
     
        private DataTable GetData()
        {
            DataTable dt = new DataTable();
     
            dt.Columns.Add("Id", typeof(int));
            dt.Columns.Add("Name", typeof(string));
            dt.Columns.Add("Date", typeof(DateTime));
            dt.Columns.Add("Bool", typeof(bool));
            dt.Columns.Add("DisplayMemberField", typeof(string));
            for (int i = 0; i < 20; i++)
            {
                string v = "Token: Id " + i + " | Name " + i;
                dt.Rows.Add(i, "Name " + i, DateTime.Now.AddDays(i), i % 2 == 0, v);
            }
     
            return dt;
        }
    }

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top