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

RadComboBoxEditor Multicolumn

9 Answers 126 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Andrew Wise
Top achievements
Rank 1
Andrew Wise asked on 10 Dec 2010, 08:49 AM
I have a grid where I succesfully manage to open a combobox editor from a cell in a heirarchial grid and make an appropriate selection using the EditorRequired and CellBeginEdit events. The problem is that I need to have two columns in the dropdown list that is displayed. I have a comments column I wish to show beside the DisplayMember column.
As an alternative I tried to get the tootiptext to work but that doesn't seem to work either. Is this implemented?

Any help would be greatly appreciated as I'm rapidly running out of time.

9 Answers, 1 is accepted

Sort by
0
Richard Slade
Top achievements
Rank 2
answered on 10 Dec 2010, 10:55 AM
Hi Andrew,

I guess you just need a multicolumncombo in your RadGridView. Is that correct? Have a look at this forum post. There are some full examples in there of creating a multicolumncombo column which should help, but let me know if you need more information
Regards,
Richard
0
Andrew Wise
Top achievements
Rank 1
answered on 10 Dec 2010, 11:11 AM
The problem is that the grid column itself is a textbox column and I create the dropdown dynamically in CellBeginEdit. When I change the RadComboBoxeditorElement to a RadMultiColumnComboBoxElement I get an error that I cannot convert to editor to this type. See the example below where I set the editorElement.

private void rgvBaseData_CellBeginEdit(object sender, GridViewCellCancelEventArgs e)
{
    RadComboBoxEditor comboEditor = rgvBaseData.ActiveEditor as RadComboBoxEditor;
    if (comboEditor != null)
    {
        ElementAttribute attribute = ((ElementAttribute)rgvBaseData.CurrentRow.DataBoundItem);
        List<ElementAttribute> attributes = _completeElementAttributeList.FindAll(f => f.ElementID == attribute.ElementID);
        RadComboBoxEditorElement editorElement = ((RadComboBoxEditorElement)comboEditor.EditorElement);
        editorElement.DropDownStyle = RadDropDownStyle.DropDownList;
        editorElement.DisplayMember = "Value";
        editorElement.ValueMember = "Value";
        editorElement.DataSource = attributes;
    }
}

I tried using RadMultiColumnComboBoxElement but I think I must also do something with the editor itself which I set in EditorRequired.

private void rgvBaseData_EditorRequired(object sender, EditorRequiredEventArgs e)
       {
           if (rgvBaseData.CurrentRow.DataBoundItem == null) return;
           if (rgvBaseData.CurrentColumn.HeaderText == Enumerators.HeaderText.Värde.ToString()
               && rgvBaseData.CurrentRow.DataBoundItem.GetType() == typeof(ElementAttribute)
               )
           {
               ElementAttribute attribute = ((ElementAttribute)rgvBaseData.CurrentRow.DataBoundItem);
               int foundCount = _completeElementAttributeList.FindAll(f => f.Name == attribute.Name && f.ElementID == attribute.ElementID).Count;
               if (foundCount > 1)
                   e.EditorType = typeof(RadComboBoxEditor);
           }
       }

We are using S.C.S.F so att present are stuck with Q1 2010 release.

/Andrew
0
Richard Slade
Top achievements
Rank 2
answered on 10 Dec 2010, 11:22 AM
Hi Andrew,

This is going to be hard for me to replicate as I am running the latest version and there are some major changes in the latest releases. Especially from 2010 Q2 onwards.

I'll have a look around the forums for you though.
Richard
0
Richard Slade
Top achievements
Rank 2
answered on 10 Dec 2010, 11:27 AM
Hi Andrew,

Have a look at this article. Even though its for Q3 it may help as it describes how tocreate a custom editor which also describes the correct places to change the editor and so forth.
Hope that helps
Richard
0
Andrew Wise
Top achievements
Rank 1
answered on 10 Dec 2010, 12:54 PM
Thanks but......
I can now create 2 columns but the columns are empty. I bind the editorElement using datasource. Driving me a bit mad this :)

public class MultiColumnEditor : BaseGridEditor
{
    public override object Value
    {
        get
        {
            RadMultiColumnComboBoxElement editor = (RadMultiColumnComboBoxElement)this.EditorElement;
            return editor.Value;
        }
        set
        {
            RadMultiColumnComboBoxElement editor = (RadMultiColumnComboBoxElement)this.EditorElement;
            if (value != null && value != DBNull.Value)
            {
                editor.Value = value;
            }
            else
            {
                editor.Value = "";
            }
        }
    }
    public override void BeginEdit()
    {
        base.BeginEdit();
        EditorElement.Focus();
  
        ((RadMultiColumnComboBoxElement)EditorElement).Columns.Clear();
  
        GridViewMultiComboBoxColumn col = new GridViewMultiComboBoxColumn();
        col.DisplayMember = "Value";
        col.ValueMember = "Value";
        col.FieldName = "Value";
        col.HeaderText = "Värde";
  
        col.Width = 100;
        ((RadMultiColumnComboBoxElement)EditorElement).Columns.Add(col);
  
        col = new GridViewMultiComboBoxColumn();
        col.DisplayMember = "Description";
        col.ValueMember = "Description";
        col.FieldName = "Description";
        col.HeaderText = "Beskrivning";
  
        col.Width = 200;
        ((RadMultiColumnComboBoxElement)EditorElement).Columns.Add(col);
  
        ((RadMultiColumnComboBoxElement)EditorElement).EditorControl.Width = 310;
    }
  
    protected override RadElement CreateEditorElement()
    {
        return new RadMultiColumnComboBoxElement();
    }
}

0
Andrew Wise
Top achievements
Rank 1
answered on 16 Dec 2010, 09:31 PM
I have finally seemed to get it to work but have a final problem.
I need the dropdown element to open docked against the right hand side of the column. i.e float over to the left.

I tried using Dock.right and alignment but nothing seems to work.

I'm doing this from the PopupOpening event.

Any help would be greatly appreciated as I feel I'm almost there now :)

/Andrew
0
Svett
Telerik team
answered on 21 Dec 2010, 01:32 PM
Hi Andrew Wise,

You should create a custom RadMultiColumnComboBoxElement:
public class MyRadMultiColumnComboBoxElement : RadMultiColumnComboBoxElement
{
    public MyRadMultiColumnComboBoxElement()
    {
        this.DropDownWidth = 50;
    }
 
    protected override RadPopupControlBase CreatePopupForm()
    {
        RadPopupControlBase popup = new MyMultiColumnComboPopupForm(this);
        return popup;
    }
 
    protected override Type ThemeEffectiveType
    {
        get
        {
            return typeof(RadComboBoxElement);
        }
    }
}
 
public class MyMultiColumnComboPopupForm : MultiColumnComboPopupForm
{
    public MyMultiColumnComboPopupForm(PopupEditorBaseElement owner)
        : base(owner)
    {
 
    }
 
    public override string ThemeClassName
    {
        get
        {
            return typeof(MultiColumnComboPopupForm).FullName;
        }
        set
        {
 
        }
    }
 
    public override void ShowPopup(Rectangle alignmentRectangle)
    {
        int delta = alignmentRectangle.Width - this.Size.Width;
 
        if (delta > 0)
        {
            alignmentRectangle.X += delta;
            alignmentRectangle.Width -= delta;
        }
 
        base.ShowPopup(alignmentRectangle);
    }
}

In addition, you need to replace the default editor by using the EditorRequired event:
this.radGridView1.EditorRequired += new EditorRequiredEventHandler(radGridView1_EditorRequired);
 
void radGridView1_EditorRequired(object sender, EditorRequiredEventArgs e)
{
    if (e.EditorType == typeof(RadMultiColumnComboBoxElement))
    {
 
        MyRadMultiColumnComboBoxElement editor = new MyRadMultiColumnComboBoxElement();
        e.Editor = editor;
    }
}

I hope this helps.

Kind regards,
Svett
the Telerik team
Check out the Q1 2011 Roadmap for Telerik Controls for Windows Forms.
0
Ariel
Top achievements
Rank 1
answered on 17 Mar 2011, 08:27 PM
HI Andrew

Can you tell me how did you sort the the issue you were having with regards to the RadMultiColumnComboBoxElement in the RadGridView not populating with data even thought you bind the control to Data

Regards

Bhavik Dhanjee
0
Svett
Telerik team
answered on 22 Mar 2011, 02:33 PM
Hi Bhavik,

I am not able to assist you with the supplied information. I would kindly ask you to open a support ticket with an enclosed sample project where the issue occurs. This will help us to understand your case in depth. In addition, could you illustrate the exact steps that we should follow to reproduce it?

Best wishes,
Svett
the Telerik team
Tags
GridView
Asked by
Andrew Wise
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Andrew Wise
Top achievements
Rank 1
Svett
Telerik team
Ariel
Top achievements
Rank 1
Share this question
or